Skip to content

Loosen typing of actions to Message#1318

Merged
sidnarayanan merged 2 commits intomainfrom
no-tools
Mar 18, 2026
Merged

Loosen typing of actions to Message#1318
sidnarayanan merged 2 commits intomainfrom
no-tools

Conversation

@sidnarayanan
Copy link
Copy Markdown
Collaborator

Companion PR to Future-House/ldp#424, turns out we already had some safeguard logic here.

Copy link
Copy Markdown
Contributor

Copilot AI 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 loosens type annotations around agent “actions” so callbacks and environment steps can accept a generic Message (while preserving runtime safeguards for non-tool actions).

Changes:

  • Broadened on_agent_action_callback types from ToolRequestMessage to Message in agent runners and LDP wiring.
  • Updated PaperQAEnvironment.step() to accept Message and perform a runtime type-check, returning a guidance message for non-tool actions.

Reviewed changes

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

File Description
src/paperqa/agents/main.py Broadens callback type annotations to accept Message instead of ToolRequestMessage.
src/paperqa/agents/env.py Broadens step() input type to Message and keeps a runtime guard for non-tool actions.

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

# if given a plain Message, or into LDP as a tool-calling SimpleAgent
# should not be responding with a plain Message
return ( # type: ignore[unreachable]
return (
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can you use the default_no_tool_calls_response you added in aviary?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Hm are you sure? I retained the logicthat was already here to avoid changing behavior. There are two differences wrt the default:

  1. slightly different message
  2. configurable reward

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Ah I see per configurable reward.

I am not attached to the "You must call tools to proceed." message. Wdyt then of default_no_tool_calls_response[0]?

Copy link
Copy Markdown
Collaborator

@jamesbraza jamesbraza left a comment

Choose a reason for hiding this comment

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

Nice

# if given a plain Message, or into LDP as a tool-calling SimpleAgent
# should not be responding with a plain Message
return ( # type: ignore[unreachable]
return (
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Ah I see per configurable reward.

I am not attached to the "You must call tools to proceed." message. Wdyt then of default_no_tool_calls_response[0]?

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Mar 17, 2026
@sidnarayanan
Copy link
Copy Markdown
Collaborator Author

@jamesbraza I feel that's less readable, I'm ok with it as-is

@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Mar 18, 2026
@sidnarayanan sidnarayanan merged commit ac4ff91 into main Mar 18, 2026
13 of 14 checks passed
@sidnarayanan sidnarayanan deleted the no-tools branch March 18, 2026 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants