Repository navigation
feat(camofox): give scheduled agents a durable browser identity - #386
leonardoag2026-beep wants to merge 3 commits into
Conversation
browser_navigate succeeded, then every following call failed with No browser session. The session map is process-local: wherever calls do not share that process, each call minted a fresh random userId, so the tab the previous call opened was invisible to the next one. Derive the ephemeral userId from (state dir, task_id) instead of uuid4, so every call in the same task resolves to the same browser user, and allow tab adoption for that reproducible identity. Unkeyed calls keep a random id, so they never collapse onto one shared profile. Closes NousResearch#215.
|
Thanks for this. A per-job browser identity for scheduled agents is a useful idea. Three things need to change before it can merge:
The tests look good: 107 pass on this head, and 3 of the new ones fail on main as they should. |
0feaaba to
6ac2bb5
Compare
|
Rebased onto #255 and reworked — all three addressed. 1. Opt-in. New While implementing that I found a sibling of the same bug: 2. No more deleting a path built from the server's internals. 3. Rebased over #255. Tests: 106 passed against current core |
…g_tab NousResearch#255 made the per-task userId reproducible, but the rebuilt session entry only re-adopted the tab when adopt_existing_tab was set, so the default config still answered 'No browser session' after navigate in another process (NousResearch#215). A task-scoped userId only ever holds this task's tabs, so the rebuild always looks for one; the per-call adopt_existing_tab gate is unchanged (a tab gone after a restart is still recreated).
A cron job outlives one run, but its browser identity did not: cron sessions
run under cron:<job_id>:<execution_id> and the execution id is new on every
fire, so each fire minted a different userId — the tab the previous fire left
was unreachable and its cookies were gone. With managed_persistence the job
instead fell back to the profile-scoped jar, sharing cookies with every other
task in the profile.
With browser.camofox.durable_agent_identity (default off) the identity comes
from the job id — the stable half of the task id — so every fire resolves to
the same Camofox profile with the logins the previous fire left:
cron:<job_id>:<execution_id> -> agent key cron:<job_id>
-> user_id hermes_ag_<uuid5(...)[:12]>
-> session_key agent_<uuid5(...)[:16]>
Derived, not stored, so it cannot drift or duplicate across processes.
Opt-in because it puts a job's cookies on disk and those profiles outlive the
job; one-off tasks (interactive chats, subagents) never join a job's profile,
and tab adoption stays the user's own choice (adopt_existing_tab).
Teardown is `hermes camofox identity <job_id>`, after `hermes cron remove`:
it closes the live session through DELETE /sessions/<userId>. The on-disk
profile belongs to the Camofox server, which exposes no route that deletes
one, so Hermes no longer rebuilds and removes the server's private
sha256(user_id)[:32] directory; the README documents the manual cleanup.
Rebased onto NousResearch#255, which makes the ephemeral identity reproducible per task.
6ac2bb5 to
2c0c323
Compare
|
Thank you @leonardoag2026-beep! This landed on main through #451, with your authorship kept; tip 269ddcb. To get it now: |
What
A cron job is an agent that outlives one run, but its browser identity did not. Cron sessions run
under
cron:<job_id>:<execution_id>, and the execution id is new on every fire, so the same jobminted a different Camofox
userIdeach time: the tab the previous fire left was unreachable and itscookies were gone. With
managed_persistence: truethe job instead fell back to the profile-scopedidentity, sharing one cookie jar with every other task in the profile — the opposite failure, since a
job that logs in should not hand those cookies to unrelated work.
This adds a durable rung keyed to the agent rather than to the task, behind an opt-in setting:
Derived, never stored, so it cannot drift or duplicate across processes. Every fire lands in the same
profile with the logins the previous fire left. One-off tasks (interactive chats, subagents) never
join a job's profile; an explicit
CAMOFOX_USER_ID/browser.camofox.user_idstill wins; tabadoption stays the user's own choice (
adopt_existing_tab) instead of being forced.Teardown:
hermes camofox identity <job_id>Closes the live session through
DELETE /sessions/<userId>, afterhermes cron remove. It does nottouch the on-disk profile: the Camofox server owns that directory and exposes no route that deletes
one, so the README documents the manual cleanup rather than rebuilding the server's private
sha256(user_id)[:32]layout and deleting it.Stacked on #255
Rebased onto #255 (beac51d): #255 makes the ephemeral identity reproducible per task, this adds the
durable rung above it.
git merge-treeagainst currentmainis clean; the diff also carries #255'scommit until it lands, and I will rebase
--onto mainonce it does.Tests
camofox/tests/test_camofox_sessions.py::TestDurableAgentIdentity— 9 new:task-scoped one
managed_persistence: trueis untouchedsubagent-*,cron:with no id) gets no durable identityDELETE), so the next fire adopts the same tabforget_agent_identityissues exactlyDELETE /sessions/<userId>and does no filesystem workFull plugin suite against current core
main(f578714e0): 106 passed. The same file on #255'shead: 97 passed, with 6 of the 9 new tests failing there.
Verified end to end against a live camofox-browser server, one process per fire: two fires of one job
resolved to the same
userIdand the same adopted tab, and a cookie set in fire 1 was still there infire 2 — after fire 1's end-of-session cleanup. A second job resolved to a different
userId; withthe setting off the same job kept the profile identity and no agent profile was created.