Description
It is currently not possible to inject custom state variables into the system prompt when using the Agent class. Even when extending AgentState with additional fields, those values are not being interpolated or made available within the prompt.
Reproduction
class State(AgentState):
occasions: str = "unknown"
SALES_PROMPT = """
Current Occasion: {occasions}
"""
agent = Agent(
model=FASHION_AGENT_MODEL,
provider=FASHION_AGENT_PROVIDER,
system_prompt=[
{
"role": "system",
"content": SALES_PROMPT,
}
],
tool_node_name="TOOL",
trim_context=True,
reasoning_config=None,
)
Expected Behavior
The {occasions} variable should be dynamically populated from the custom State object and rendered inside the system prompt.
Actual Behavior
The {occasions} placeholder is not resolved, and the prompt does not reflect the custom state value.
Impact
This prevents developers from using dynamic, state-driven context in prompts, limiting flexibility for real-world use cases such as personalization or contextual workflows.
Suggested Solution
- Allow automatic interpolation of custom
AgentState fields into prompts.
- Alternatively, provide a documented hook or method to manually inject state into the prompt at runtime.
Additional Context
This feature is critical for building context-aware agents where prompt behavior depends on evolving internal state.
Description
It is currently not possible to inject custom state variables into the system prompt when using the
Agentclass. Even when extendingAgentStatewith additional fields, those values are not being interpolated or made available within the prompt.Reproduction
Expected Behavior
The
{occasions}variable should be dynamically populated from the customStateobject and rendered inside the system prompt.Actual Behavior
The
{occasions}placeholder is not resolved, and the prompt does not reflect the custom state value.Impact
This prevents developers from using dynamic, state-driven context in prompts, limiting flexibility for real-world use cases such as personalization or contextual workflows.
Suggested Solution
AgentStatefields into prompts.Additional Context
This feature is critical for building context-aware agents where prompt behavior depends on evolving internal state.