Skip to content

Fix sidepanel chat context-limit recovery - #1110

Closed
Mike Hjazeen (Agentic Labs) (mjjjjaazing) wants to merge 1 commit into
browseros-ai:mainfrom
mjjjjaazing:codex/context-limit-recovery
Closed

Mike Hjazeen (Agentic Labs) (mjjjjaazing) wants to merge 1 commit into
browseros-ai:mainfrom
mjjjjaazing:codex/context-limit-recovery

Conversation

@mjjjjaazing

Copy link
Copy Markdown

Summary

  • detect provider context-limit errors from sidepanel chat streams and thrown stream setup errors
  • compact prior sidepanel chat history into a structured continuation note, rebuild the session, and retry once
  • preserve already-visible assistant progress on mid-stream recovery while suppressing the duplicate retry start event
  • add regression coverage for pre-output and partial-output context-limit failures

Tests

  • bun --env-file=.env.development test --preload=./tests/__helpers__/test-env.ts ./tests/api/services/chat-service.test.ts
  • bun run typecheck
  • bun run test:api
  • git diff --check

@greptile-apps

greptile-apps Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

PR author is not in the allowed authors list.

@shadowfax92

Copy link
Copy Markdown
Contributor

Thanks so much for contributing to BrowserOS! 🙏

We're doing some housekeeping on our PR queue and closing out PRs that have been open for more than 7 days. This isn't a reflection on your work — we really appreciate the time and effort you put in.

If this is still relevant, please feel free to reopen it or open a fresh PR and we'll take another look. Thanks again for being part of the project! 🚀

Dmitrii Vasilev (gHashTag) added a commit to gHashTag/BrowserOS that referenced this pull request Sep 4, 2026
…browseros-ai#1111) (#308)

Two bees ran in parallel with disjoint boundaries (browseros-ai#1110 owned
rings/SR-02/QueenBranchCommitter.swift, browseros-ai#1109 owned
rings/SR-02/ChatViewModel.swift and rings/SR-00/QueenReviewVerdictRequest.swift).
browseros-ai#1110 made baseBranch() return String?, exactly as its criterion asked; the
call site lived in the other bee's file. Both honoured the one-owner-per-path
rule and the build broke:

    rings/SR-02/ChatViewModel.swift:4142: error: value of optional type
    'String?' must be unwrapped to a value of type 'String'

The boundary rule protects against a conflict of writes. It says nothing about
a conflict of interfaces: a signature changed in one file breaks a different
file, and only a build of the two states together can see it. The
acceptance-side half landed with browseros-ai#1128 (runInterfaceDivergenceWatchdog
compiles the combined state before any acceptance; transitionToAccepted takes
the proof as a parameter, so no path to .accepted can skip it). What remained
open was the issue's second criterion: drift-guard judges two worktrees it
builds itself, not two states of this tree, so returning the former behaviour
moved nothing.

This file closes that gap with the decision itself, as a pure rule:

- QueenInterfaceDivergence.verdict(between:) takes the interface facts of each
  lane (declarations whose shape changed, calls and the shapes they expect),
  overlays the lanes the way verifyCombinedBuild overlays branches, and
  reports every call that no longer matches, plus the two-changers-one-
  declaration case. Findings name both sides - who changed what, and who
  still calls the old shape - because a refusal that does not name its
  subject sends the reader hunting for the wrong problem.
- The single-file suite rides in the same file behind
  QUEEN_INTERFACE_DIVERGENCE_SELFTEST and runs on the incident's own facts:
  the browseros-ai#1110/browseros-ai#1109 pair is refused, while a change whose call moved with it, a
  body-only change, and a new call written against the new shape all pass.
  The block holds declarations only: -emit-module typechecks even inactive
  #if branches (measured on the container), so a top-level entry would break
  the app build; the documented one-line driver keeps the file buildable and
  the suite runnable where no linker exists.
- The revert proof is executable: formerIsolatedVerdict restates the
  pre-browseros-ai#1111 loop (each lane judged alone, nothing crosses a boundary) and the
  suite shows it accepts the incident pair that the rule refuses. Revert the
  rule to that judgement and the incident scenario fails its first check -
  the check breaks. Verified live against two mutants (the isolated revert
  and a blanket-refuse revert): both fail the suite loudly and non-zero.

Nothing is imported, not even Foundation, so the rule compiles anywhere the
Swift standard library does and the suite runs interpreted on the Linux
container: 17 checks, 0 failures, parse/typecheck/emit-module green with the
flag both off and on.

Co-authored-by: queen-1111 bee <bee@trios.local>
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.

2 participants