Skip to content

Conversation

@awadell1
Copy link
Collaborator

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:

  1. No longer put non-state (i.e. workspace) into the Agent state. They can instead go into the context and get propagated to the tool directly
  2. Added a store, allowing tools/agents to access application-level logic (Think API Keys, or edit files lists). For the write/edit code tools this let us decouple the tools from the calling agent's state. Previously these tools required the calling agent to specify "code_files" in their state

@mikegros as a side effect, I think this also fixes the parallel tool call error when calling write_code/edit_code

@mikegros mikegros self-requested a review January 26, 2026 21:38
from ursa.tools.write_code_tool import edit_code, write_code


def test_write_code_strips_fences_and_writes(tmp_path: Path):
Copy link
Collaborator

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).

Copy link
Collaborator

@mikegros mikegros left a 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":
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
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]
Copy link
Collaborator

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.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants