-
Notifications
You must be signed in to change notification settings - Fork 20
Restrict commands/filenames to ASCII and uses the tool runtime #158
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
base: main
Are you sure you want to change the base?
Conversation
breaking: file edits are limited to 1k edits (previously unbounded)
DDGS is flaky, stub it to avoid test errors
| from ursa.tools.write_code_tool import edit_code, write_code | ||
|
|
||
|
|
||
| def test_write_code_strips_fences_and_writes(tmp_path: Path): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can actually remove this test because it looks like we are going to remove the _strip_fences function (because it actually causes problems instead of fixing them now).
mikegros
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll look over more but wanted to get this out to you.
| print("[READING]: ", full_filename) | ||
| try: | ||
| if full_filename.lower().endswith(".pdf"): | ||
| if full_filename.suffix == ".pdf": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if full_filename.suffix == ".pdf": | |
| if full_filename.suffix.lower() == ".pdf": |
Doesn't this need to keep the "lower" to ensure it's not case sensitive (some pdf files end in .PDF rather than .pdf for instance)
|
|
||
| def safety_check(self, state: ExecutionState) -> ExecutionState: | ||
| def safety_check( | ||
| self, state: ExecutionState, runtime: Runtime[AgentContext] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This appears to fail for me in any uses of the execution agent that traverse the graph because it needs two arguments but in the graph it only gets the state passed into it.
Update type annotation on run_command, write_code and edit_code to restrict filenames/commands to "text" ASCII (so no command symbols). This turns out to be zero cost on OpenAI as they support providing a grammar for decoding
Along the way, also swapped the tools to use LangGraph's ToolRuntime (instead of the older split out types). The win here:
@mikegros as a side effect, I think this also fixes the parallel tool call error when calling write_code/edit_code