fix(agents,failover): propagate sessionId/lane/provider attribution through FailoverError#73506
Conversation
Greptile SummaryThis PR extends Confidence Score: 5/5Safe to merge — additive, non-breaking changes with good test coverage and no logic regressions. All changes are purely additive optional fields. The public API is extended without altering existing call-site contracts. Tests verify both the constructor round-trip and the coerceToFailoverError enrichment path. No existing behaviour is removed or altered. No files require special attention. Reviews (1): Last reviewed commit: "fix(agents,failover): propagate sessionI..." | Re-trigger Greptile |
|
Codex review: needs changes before merge. What this changes: The PR adds optional sessionId/lane attribution to FailoverError and FallbackSummaryError, threads it through selected failover logging and CLI/embedded/auto-reply/cron call paths, adds targeted tests, and adds a changelog entry. Required change before merge: The remaining blocker is a narrow, source-level propagation gap with clear files and validation paths, so an automated repair on this PR branch or a replacement branch is reasonable. Security review: Security review cleared: The diff changes TypeScript failover attribution plumbing, tests, and changelog text; it does not touch workflows, dependencies, lockfiles, install or release scripts, package publishing metadata, secrets handling, or downloaded artifacts. Review findings:
Review detailsBest possible solution: Land this as a complete attribution fix only after every fallback boundary that can produce exhausted wrapper errors supplies the available session and lane context, with regression coverage for the direct agent-command and queued follow-up paths. Keep session-id normalization as a separate follow-up unless the maintainer chooses to include it deliberately. Do we have a high-confidence way to reproduce the issue? Yes. A high-confidence static reproduction path exists: exhaust model fallback through the direct agent-command path or queued follow-up runner, where session context exists but is not passed to runWithModelFallback, then inspect the final FallbackSummaryError or model_fallback_decision structured fields. Is this the best way to solve the issue? No. The helper and selected call-site changes are directionally right, but the PR is not yet the narrow complete fix while central callers still omit the metadata needed for session_id attribution. Full review comments:
Overall correctness: patch is incorrect Acceptance criteria:
What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against a379ac056261. |
…hrough FailoverError Adds optional `sessionId` and `lane` fields to `FailoverError` and threads them — together with the existing `provider`, `model`, `profileId` — through `describeFailoverError` and `coerceToFailoverError` context, so structured error log ingestion can attribute exhausted-fallback wrapper errors back to the originating request instead of dropping the per-profile metadata when the final wrapper is built. Fixes openclaw#42713.
408e1e0 to
26fdb9a
Compare
|
Merged via squash.
Thanks @wenxu007! |
…hrough FailoverError (openclaw#73506) * fix(agents,failover): propagate sessionId/lane/provider attribution through FailoverError Adds optional `sessionId` and `lane` fields to `FailoverError` and threads them — together with the existing `provider`, `model`, `profileId` — through `describeFailoverError` and `coerceToFailoverError` context, so structured error log ingestion can attribute exhausted-fallback wrapper errors back to the originating request instead of dropping the per-profile metadata when the final wrapper is built. Fixes openclaw#42713. * fix: preserve failover error attribution --------- Co-authored-by: Altay <[email protected]>
…hrough FailoverError (openclaw#73506) * fix(agents,failover): propagate sessionId/lane/provider attribution through FailoverError Adds optional `sessionId` and `lane` fields to `FailoverError` and threads them — together with the existing `provider`, `model`, `profileId` — through `describeFailoverError` and `coerceToFailoverError` context, so structured error log ingestion can attribute exhausted-fallback wrapper errors back to the originating request instead of dropping the per-profile metadata when the final wrapper is built. Fixes openclaw#42713. * fix: preserve failover error attribution --------- Co-authored-by: Altay <[email protected]>
…hrough FailoverError (openclaw#73506) * fix(agents,failover): propagate sessionId/lane/provider attribution through FailoverError Adds optional `sessionId` and `lane` fields to `FailoverError` and threads them — together with the existing `provider`, `model`, `profileId` — through `describeFailoverError` and `coerceToFailoverError` context, so structured error log ingestion can attribute exhausted-fallback wrapper errors back to the originating request instead of dropping the per-profile metadata when the final wrapper is built. Fixes openclaw#42713. * fix: preserve failover error attribution --------- Co-authored-by: Altay <[email protected]>
…hrough FailoverError (openclaw#73506) * fix(agents,failover): propagate sessionId/lane/provider attribution through FailoverError Adds optional `sessionId` and `lane` fields to `FailoverError` and threads them — together with the existing `provider`, `model`, `profileId` — through `describeFailoverError` and `coerceToFailoverError` context, so structured error log ingestion can attribute exhausted-fallback wrapper errors back to the originating request instead of dropping the per-profile metadata when the final wrapper is built. Fixes openclaw#42713. * fix: preserve failover error attribution --------- Co-authored-by: Altay <[email protected]>
…hrough FailoverError (openclaw#73506) * fix(agents,failover): propagate sessionId/lane/provider attribution through FailoverError Adds optional `sessionId` and `lane` fields to `FailoverError` and threads them — together with the existing `provider`, `model`, `profileId` — through `describeFailoverError` and `coerceToFailoverError` context, so structured error log ingestion can attribute exhausted-fallback wrapper errors back to the originating request instead of dropping the per-profile metadata when the final wrapper is built. Fixes openclaw#42713. * fix: preserve failover error attribution --------- Co-authored-by: Altay <[email protected]>
Summary
Threads originating-request attribution (
sessionId,lane) plus the existingprovider,model,profileIdthroughFailoverError,describeFailoverError, andcoerceToFailoverErrorso structured error-log ingestion (e.g.gateway.err.log→api_health_log) can attribute exhausted-fallback wrapper errors back to the originating session and last-attempted provider.Root cause
Per the issue, ~18% of recent gateway errors had no
providerorsession_idpopulated. The underlying per-profile errors carried that metadata, but the finalFailoverErrorwrapper produced after all profiles/models were exhausted dropped it: the class only storedprovider/model/profileId,describeFailoverErroronly re-exposedmessage/rawError/reason/status/code, andcoerceToFailoverErroraccepted no session-level context. Downstream loggers therefore had nothing to log.Change
src/agents/failover-error.ts:FailoverErrorgains optionalreadonly sessionId?: stringandreadonly lane?: string, populated from new constructor params (additive, fully backward-compatible).describeFailoverError(err)now also returnsprovider,model,profileId,sessionId,lanewhen the error is aFailoverError. For non-FailoverErrorinputs it surfaces the recoveredsignal.providerso the at-the-throw provider context is preserved.coerceToFailoverError(err, context)acceptssessionIdandlaneincontextand threads them into the constructedFailoverError. Provider falls back tosignal.providerwhen no context provider is given.No call-site changes are required to land — existing callers continue to work, and code that currently passes
{ provider, model, profileId }can incrementally start passingsessionId/lanefrom runner/lane context.Tests
src/agents/failover-error.test.ts:propagates sessionId/lane/provider attribution through FailoverError (#42713)— constructs aFailoverErrorwith the new fields and asserts both the instance fields anddescribeFailoverError(err)round-trip.coerceToFailoverError carries sessionId/lane from context (#42713)— asserts the context fields land on the resultingFailoverError.Notes
session:vs raw) was called out by the reporter as a secondary concern. Leaving that to a follow-up so this change stays a non-breaking type-additive propagation patch — oncesessionIdis plumbed through, normalization can happen at one well-defined boundary.Closes #42713.