Skip to content

Generate a default thread_id instead of sharing one constant - #335

Open
arpitjain099 wants to merge 1 commit into
lanl:mainfrom
arpitjain099:fix/default-thread-id-unique
Open

Generate a default thread_id instead of sharing one constant#335
arpitjain099 wants to merge 1 commit into
lanl:mainfrom
arpitjain099:fix/default-thread-id-unique

Conversation

@arpitjain099

Copy link
Copy Markdown

Closes #332.

BaseAgent defaulted thread_id to 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:185 sets its own self.config.thread_id or "ursa" and passes it explicitly at :355, and ursa_dashboard/worker_main.py:272 sets agent_init["thread_id"] = "ursa". Both keep the behaviour they have. experimental/agents/multiagent.py and simulator_agent.py already 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:

thread ids: ursa ursa
BLEED

After:

thread ids: b71dfa9edc5347ce8e0d7e32ba6421b1 9a1940242567444f94f8002337fe7f7e
ISOLATED

Two tests added to tests/agents/test_base/test_base.py: two agents built without a thread_id get different ones, and an explicit thread_id is still honoured, which is the property the CLI depends on. The first fails on the current code with assert 'ursa' != 'ursa'.

pytest tests/agents/test_base/test_base.py goes 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 check reports the same 54 errors either way and ruff format --check is clean.

Worth noting for #331: this stops a library caller resuming by agent_name alone from silently landing in another agent's thread, but it does not change the append-instead-of-restore behaviour itself.

Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
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.

Library default thread_id is a constant, so a shared checkpoint store merges unrelated agents

1 participant