Skip to content

Clarification on bypass_state_injection usage in _process_agent_instruction #3790

Description

@wmsnp

I’m trying to understand the rationale behind the bypass_state_injection flag in the _process_agent_instruction function:

async def _process_agent_instruction(
    self, agent, invocation_context: InvocationContext
) -> str:
    """Process agent instruction with state injection."""
    raw_si, bypass_state_injection = await agent.canonical_instruction(
        ReadonlyContext(invocation_context)
    )
    si = raw_si
    if not bypass_state_injection:
        si = await instructions_utils.inject_session_state(
            raw_si, ReadonlyContext(invocation_context)
        )
    return si

Currently, it seems that the necessity of bypassing state injection is determined by whether the “instruction” is a string or a callable. In my use case, I am using a third-party tool to manage instructions dynamically, which means the instruction cannot be represented as a simple string—but that doesn’t necessarily mean it shouldn’t have state injected.

Could you clarify the intended use of bypass_state_injection and whether there’s a recommended approach for handling instructions that are not strings but still require session state injection?

Thanks in advance!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    core[Component] This issue is related to the core interface and implementationquestion[Component] This issue is asking a question or clarification

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions