Skip to content

How to pass session to guardrail #1690

@galshi

Description

@galshi

Question

I’m building an input guardrail for a chatbot that needs to detect repeated questions, so it has to see the previous conversation.

I’m using SQLiteSession (but this applies to anything from SessionABC, not sure about Conversations API memory). The docs don’t show passing session data. I tried putting the session in the context, which works but feels hacky. Then I hit this error:

agents.exceptions.UserError: Cannot provide both a session and a list of input items. When using session memory, provide only a string input to append to the conversation, or use session=None and provide a list to manually manage conversation history.

I can work around it, but it feels like too much hassle for something that sounds like a common use case. Am I doing something wrong, is this a reasonable way to use an input guardrail?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionQuestion about using the SDK

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions