Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

Commits on main

fix(thread): upsert cached messages by id
Shanu committed 3 months ago
9d99a50
838c3aa
style: prettier formatting for the routing dialog test
Guy Kaganovsky committed 3 months ago
7e15155
2be4edd
36b1e7a
fix(search): do not reuse the cached bearer token after a local sign-out\n\nCodeRabbit flagged the `(None, Some(cached))` arm of `resolve_client`, and it\nholds up: `build_client` answers `None` only when the store has no usable\napp-session JWT — it logs that case as "no auth token available — user is not\nsigned in", not as a transient lookup failure. Falling back to the cached\nclient there posts the pre-sign-out bearer token, so a `WebSearchTool` that\noutlived a local sign-out could keep making authenticated backend requests with\na credential the user had already revoked.\n\nThe fallback now depends on WHY there is no fresh client:\n\n - `root_config` supplied, no fresh client -> the store says signed out, so\n return `None` and fail locally.\n - no `root_config` -> nothing to re-resolve against, so the client the tool\n was built with remains the only truth available; fallback kept.\n\nTwo test changes alongside it.\n\n`test_keeps_cached_client_when_its_token_is_still_current` could not observe\nwhat it claimed. Both the cached client and a rebuilt one carry\n`Bearer same-token`, so asserting on the header alone passed whether or not\n`resolve_client` rebuilt on every request. The cached client now points at a\nSEPARATE mock backend, and the test asserts that backend served the request and\nthat the rebuild backend was never reached — the client choice is now visible.\n\n`test_signed_out_store_does_not_reuse_the_cached_bearer_token` is new and is\nthe regression test for the fix: a tool holding a client built while signed in,\nagainst a config whose profile store is empty. The mock backend fails the test\nif it is reached at all, because after sign-out the right behaviour is to\nrefuse locally rather than send a request that merely gets rejected remotely.\n
M3gA-Mind committed 3 months ago
ebad9bf
fix(search): refresh the session token before the request, not after a 401\n\nThe retry ran after the failure it was recovering from, and that failure is\nnot free. `/agent-integrations/parallel/search` is a POST, so it takes the\nnon-soft branch of `handle_session_jwt_unauthorized`, which publishes\n`DomainEvent::SessionExpired`; `SessionExpiredSubscriber` answers that with an\nunconditional `clear_session` and never compares the rejected token against the\nstored one. The retry could therefore succeed with the freshly-read JWT and the\nqueued event would then delete that same JWT — one working search followed by an\nunexplained sign-out.\n\nResolve the client before the request instead: if the credential store holds a\ndifferent token than the one baked into the cached client, use a client built\nfrom the store. The stale-token 401 is never provoked, so there is no teardown\nto race. A genuinely dead session still 401s and still tears down, which is the\ncorrect outcome and is left alone.\n\nAlso covers the tool built while signed out (`client: None`), which previously\nstayed dead until the tool registry was rebuilt.\n\nTests now pin the behaviour rather than the pre-existing error path: assert on\nthe Authorization header the backend actually received, for both the superseded\ntoken (must send the refreshed one) and the unchanged token (must not swap).\nThe prior test used a 500, which never reaches the SESSION_EXPIRED branch, and\npassed identically with the change reverted. Restores the\n`test_execute_without_backend_client` assertion that was widened to an `||` —\nthe new message still contains "backend session token" verbatim.\n\nRefs #5873\n
M3gA-Mind committed 3 months ago
2157ed5