Skip to content

Recover bridge sessions after context overflow#344

Merged
marccampbell merged 2 commits into
mainfrom
fix-context-overflow-recovery
Jun 4, 2026
Merged

Recover bridge sessions after context overflow#344
marccampbell merged 2 commits into
mainfrom
fix-context-overflow-recovery

Conversation

@marccampbell

Copy link
Copy Markdown
Contributor

Summary

  • create a fresh OpenClaw gateway session after recoverable send failures such as context overflow, prompt-too-large, or model deadline errors
  • retry the triggering message once in the fresh session instead of surfacing repeated claw-bridge errors in chat
  • reset saved session key/context usage after recovery

Tests

  • env GOCACHE=/private/tmp/elasticclaw-go-build go test ./cmd/claw-bridge
  • env GOCACHE=/private/tmp/elasticclaw-go-build go test ./...

@greptile-apps

greptile-apps Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "Recover bridge sessions after context ov..." | Re-trigger Greptile

Comment thread cmd/claw-bridge/main.go Outdated
Comment thread cmd/claw-bridge/main.go Outdated
Comment on lines +1443 to +1448
retryCtx := ctx
retryCancel := func() {}
if ctx.Err() != nil {
retryCtx, retryCancel = context.WithTimeout(context.Background(), 30*time.Minute)
}
defer retryCancel()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Expired caller context replaced with 30-minute window on retry

When ctx.Err() != nil, the original request was already cancelled or timed out by the caller. Instead of aborting, this branch silently discards the caller's intent and retries with a brand-new context.WithTimeout(..., 30*time.Minute). For a legitimate server-side deadline error the original context should still be valid; the ctx.Err() != nil branch should return early rather than substitute a new context.

Comment thread cmd/claw-bridge/main_test.go Outdated
@greptile-apps

greptile-apps Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Reviews (2): Last reviewed commit: "Respect caller cancellation during sessi..." | Re-trigger Greptile

@marccampbell marccampbell merged commit b1df737 into main Jun 4, 2026
11 checks passed
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.

1 participant