Skip to content

How to pass hardcoded dynamic messages as agent's responses in the chat history ? #695

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
HG2407 opened this issue May 15, 2025 · 4 comments
Labels
question Question about using the SDK stale

Comments

@HG2407
Copy link

HG2407 commented May 15, 2025

Please read this first

  • Have you read the docs?Agents SDK docs
  • Have you searched for related issues? Others may have had similar requests

Question

Suppose I have a todo tracking agent, which tracks the todo tasks of a user. Now on the first message I want to provide the list of todo tasks of the user with a properly phrased hardcoded message from my end. I also want the model to have context of these tasks. I can't add these todo tasks in the system prompt. What are my options ?

I tried doing this:

input_items.append({'role': 'assistant', 'id': "msg_MADE_UP_ID", 'content': [{'annotations': [], 'text': hardcoded_content, 'type': 'output_text'}], 'status': 'completed', 'type': 'message'})
input_items.append({"content": user_input, "role": "user"})
result = await Runner.run(current_agent, input_items, context=context)

But I get this error:

openai.NotFoundError: Error code: 404 - {'error': {'message': "Item with id 'msg_MADE_UP_ID' not found.", 'type': 'invalid_request_error', 'param': 'input', 'code': None}}

@HG2407 HG2407 added the question Question about using the SDK label May 15, 2025
@HG2407
Copy link
Author

HG2407 commented May 15, 2025

I want to pass this hardcoded content as the first message of the chat. Is there a separate type: system similar to user and assistant ?

@rm-openai
Copy link
Collaborator

Just don't set the ID.


    agent = Agent(name="Assistant")

    inputs = [
        {"role": "user", "content": "What's your name?"},
        {"role": "assistant", "content": "My name is Jimmy the AI, how can I help you today?"},
        {"role": "user", "content": "What's your name again?"},
    ]

    result = await Runner.run(agent, inputs)

@rm-openai
Copy link
Collaborator

And yes, valid roles are "user", "assistant", "system", "developer"

Copy link

This issue is stale because it has been open for 7 days with no activity.

@github-actions github-actions bot added the stale label May 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question about using the SDK stale
Projects
None yet
Development

No branches or pull requests

2 participants