-
Notifications
You must be signed in to change notification settings - Fork 165
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bridge() solver for integrating with external agent frameworks #1181
Draft
jjallaire
wants to merge
38
commits into
main
Choose a base branch
from
feature/solver-bridge
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,062
−660
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jjallaire
changed the title
bridge() function for converting agents with no inspect dependencies into solvers
bridge() solver for integrating with external agent frameworks
Jan 23, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces the ability to integrate an external agent with no Inspect dependencies by converting
it to a Solver. The only requirements of the agent are that it use the standard OpenAI API and that it consume and produce
dict
values as described below. While the agent function calls the standard OpenAI API, these calls are intercepted by Inspect and sent to the requisite Inspect model provider.Protocol
Here is the type contract for bridged solvers (you don't need to use or import these types in your agent, your
dict
usage should just conform to the protocol):The agent function must be async, and should accept and return
dict
values as-per the type declarations (you aren't required to use these types exactly (they merely document the requirements) so long as you consume and producedict
values that match their declarations.Returning
messages
is not required but is highly recommended so that people running the agent can see the full message history in the Inspect log viewer.Returning
scores
is entirely optional (most agents will in fact rely on Inspect native scorers, this is here as anescape hatch for agents that want to do their own scoring).
Example
Here is the simplest possible agent definition:
Note that you should always pass the "model" along to OpenAI exactly as passed in the sample. While you are calling the standard OpenAI API, these calls are intercepted by Inspect and sent to the requisite Inspect model provider.
Here is how you can use the
bridge()
function to use this agent as a solver:"""
Inspect Features
The
bridge()
function enables you to create an agent with zero Inspect dependencies and still get the benefit of most of Inspect's infrastructure.Limits
Sample level token and time limits are are enforced as normal with bridged solvers. Message limits are enforced when calling the main model being evaluated (the number of messages sent to the model are counted and compared against the limit).
Observability
Agents incorporated using the
bridge()
function still get to take advantage of most of Inspect's core observability features --- all model calls still go through the Inspect model interface so appear in the transcript as normal. If you returnmessages
in your result then themessages
are also populated for the log viewer. Standard Python logger calls also continue to be routed into the Inspect sample log.If you want to take advantage of additional observability features you can optionally import the Inspect
transcript()
function and use it as normal.Sandboxes
If you need to execute arbitrary model generated code, you can use the Inspect
sandbox()
functions directly. If you need your agent to run both inside and outside of Inspect you can abstract code execution into an interface and only callsandbox()
when running inside the Inspect agent wrapper.