Skip to content

Load system_prompt with decorator using AGUIAdapter #3315

@dav04

Description

@dav04

Initial Checks

Description

Following this example to implement the AG-UI protocol:

agent = Agent('openai:gpt-5')

app = FastAPI()


@app.post('/')
async def run_agent(request: Request) -> Response:
    accept = request.headers.get('accept', SSE_CONTENT_TYPE)
    try:
        run_input = AGUIAdapter.build_run_input(await request.body())  # 
    except ValidationError as e:
        return Response(
            content=json.dumps(e.json()),
            media_type='application/json',
            status_code=HTTPStatus.UNPROCESSABLE_ENTITY,
        )

    adapter = AGUIAdapter(agent=agent, run_input=run_input, accept=accept)
    event_stream = adapter.run_stream() # 

    sse_event_stream = adapter.encode_stream(event_stream)
    return StreamingResponse(sse_event_stream, media_type=accept)

If I pass system_prompt directly to the agent or if I use the decorator like this, the agent is executed without the system_prompt:

@agent.system_prompt
def get_agent_instructions(ctx: RunContext[str]) -> str:
    print('----LOADING PROMPT----')  # this is not printed
    return 'Be fun!'

Instead if I use the instructions parameter, agent return a compliant response with the prompt.

Is it possible that AGUIAdapter does not consider system_prompt parameter during execution?

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions