Skip to content

How can I pass dynamic instruction to the agent #482

Closed as not planned
Closed as not planned
@Salaudev

Description

@Salaudev

I want to implement a handoff agent, but in this agent I have dynamic data in the system prompt.

Image

i was thinking to do smth like that

def run_rate_negotiator(ctx: RunContextWrapper[Any]):
    conversation = ctx.context["conversation_history"]
    query = ctx.context["text_query"]
    conversation.append({"role": "user", "content": query})

    rate_negotiator = Agent(
        name="rate_negotiator",
        instructions=get_rate_negotiator_instructions(ctx.context["company_info"], ctx.context["load_context"]),
        model=OpenAIChatCompletionsModel(model=openai_deployment_name, openai_client=azure_client),
        tools=[...]
    )

    try:
        result = Runner.run(rate_negotiator, input=conversation, context=ctx.context)
        return result
    except Exception as e:
        print(f"Error in run_rate_negotiator: {str(e)}")
        error_json = '{"error": "Failed to process rate negotiation: ' + str(e) + '"}'
        return error_json

To pass handoff agent to a main agent, I need the following
Image

Can anyone help me with this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionQuestion about using the SDKstale

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions