Skip to content

馃悰 Bug Report: Cannot Use Custom State Variables in Agent Prompt#62

Description

@Iamsdt

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions