Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add GuardrailAgent prompt param support#32

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed

Conversation

@gabor-openai
Copy link
Collaborator

Via bug report:

One minor thing, it seems like your Guardrail Agent isn't a 1:1 drop in for the Agents SDK, using a remote prompt gives me an error.

TypeError: GuardrailAgent.__new__() missing 1 required positional argument: 'instructions'

Copy link

CopilotAI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Pull Request Overview

This PR adds support for aprompt parameter toGuardrailAgent to make it a 1:1 drop-in replacement for the Agents SDK. Previously,GuardrailAgent required aninstructions parameter, but the Agents SDK allows using aprompt parameter instead.

  • Added_resolve_agent_instructions helper function to derive instructions from either explicit instructions or prompt parameters
  • ModifiedGuardrailAgent.__new__ to accept optionalinstructions and handleprompt parameter viaagent_kwargs
  • Added validation to ensure eitherinstructions orprompt is provided during initialization

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

FileDescription
src/guardrails/agents.pyAdded prompt parameter support and instruction resolution logic to GuardrailAgent
tests/unit/test_agents.pyAdded test cases for prompt parameter functionality and updated Agent stub

💡Add Copilot custom instructions for smarter, more guided reviews.Learn how to get started.

prompt_arg:Any|None=agent_kwargs.get("prompt")
resolved_instructions=_resolve_agent_instructions(instructions,prompt_arg)

ifresolved_instructionsisNoneandprompt_argisNone:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

The validation logic is incorrect. The condition should check ifresolved_instructions is None, not bothresolved_instructions is None and prompt_arg is None. If a prompt is provided but doesn't yield valid instructions (e.g., an object without the expected attributes), the agent should still fail to initialize.

Suggested change
ifresolved_instructionsisNoneandprompt_argisNone:
ifresolved_instructionsisNone:

Copilot uses AI. Check for mistakes.
Comment on lines +15 to +17
guardrails_pkg=types.ModuleType("guardrails")
guardrails_pkg.__path__= [str(Path(__file__).resolve().parents[2]/"src"/"guardrails")]
sys.modules.setdefault("guardrails",guardrails_pkg)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This module setup code should be moved to a test fixture or conftest.py rather than being placed at module level. Module-level sys.modules manipulation can cause issues with test isolation and make debugging more difficult.

Copilot uses AI. Check for mistakes.
Copy link

CopilotAI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Pull Request Overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.


💡Add Copilot custom instructions for smarter, more guided reviews.Learn how to get started.

Copy link
Collaborator

@steven10asteven10a left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggest closing in favor ofPR 34

@gabor-openai
Copy link
CollaboratorAuthor

gabor-openai commentedOct 30, 2025
edited
Loading

Closing in favor of#34

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

Reviewers

@steven10asteven10asteven10a left review comments

Copilot code reviewCopilotCopilot left review comments

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@gabor-openai@steven10a

[8]ページ先頭

©2009-2025 Movatter.jp