Generate a default thread_id instead of sharing one constant - #335
Open
arpitjain099 wants to merge 1 commit into
Open
Generate a default thread_id instead of sharing one constant#335arpitjain099 wants to merge 1 commit into
arpitjain099 wants to merge 1 commit into
Conversation
Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
This file contains hidden or 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
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.
Closes #332.
BaseAgentdefaultedthread_idto the literal"ursa", so every agent built without one wrote to the same thread of whatever checkpointer it was handed. Two agents sharing a store therefore shared a conversation, and the second one's model request carried the first one's messages.Restored to
uuid4().hex, which is what the constructor docstring three hundred lines up still promises ("Unique identifier for this agent instance. Generated if not provided") and what the code did before #246 extended the CLI's constant into the library constructor.I checked that this does not disturb the callers that want a shared thread, since that was my first worry about changing a default.
cli/runtime.py:185sets its ownself.config.thread_id or "ursa"and passes it explicitly at :355, andursa_dashboard/worker_main.py:272setsagent_init["thread_id"] = "ursa". Both keep the behaviour they have.experimental/agents/multiagent.pyandsimulator_agent.pyalready suffix a caller-supplied id per sub-agent, so they are unaffected too. The default is reached only by library callers, which is where the bleed was.Verified with the reproducer from the issue, which needs no API keys. Before the change:
After:
Two tests added to
tests/agents/test_base/test_base.py: two agents built without athread_idget different ones, and an explicitthread_idis still honoured, which is the property the CLI depends on. The first fails on the current code withassert 'ursa' != 'ursa'.pytest tests/agents/test_base/test_base.pygoes from 9 passed to 11 passed. The ten failures in that file are the same ten before and after this branch, all in the persistent-agent async sqlite tests, and I checked that rather than assuming it.ruff checkreports the same 54 errors either way andruff format --checkis clean.Worth noting for #331: this stops a library caller resuming by
agent_namealone from silently landing in another agent's thread, but it does not change the append-instead-of-restore behaviour itself.