Skip to content

Bound tool output and recover oversized model context - #52

Merged
Telli merged 6 commits into
mainfrom
codex/runtime-resilience
Nov 6, 2026
Merged

Telli merged 6 commits into
mainfrom
codex/runtime-resilience

Conversation

@Telli

@Telli Telli commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Large tool responses now keep a bounded head/tail preview in model context while preserving complete tool results, events, and immutable session artifacts. The permission-aware read_tool_output tool retrieves those artifacts in bounded Unicode-safe windows. Storage is partitioned by tenant and session, and retrieval accounts for JSON escaping to avoid recursively archiving oversized pages.

Oversized histories compact through bounded summarization calls that carry validated working state forward. Only the completed replacement is persisted; cancellation, invalid later chunks, and call-limit failures never publish partial state. Explicit provider context overflow permits one forced-compaction recovery per agent invocation, with fresh stream buffers and no replay of already executed tools.

Stacked on #51. The base is intentionally codex/snapshot-compaction-live-control so this PR shows only the resilience milestone. Retarget to main after #51 merges.

Validation

  • dotnet build SharpClawCode.sln --configuration Release --warnaserror --no-restore — zero warnings/errors
  • dotnet test SharpClawCode.sln --configuration Release --no-build --no-restore — 469 passed: 318 unit, 131 integration, 20 parity
  • Artifact restart recovery, session/tenant isolation, malformed IDs, permission allow-list denial, Unicode paging, JSON preview budgets, and cancellation cleanup
  • Multi-chunk context budgets, aggregate usage, chunk failure/call limits, one-shot overflow recovery, and discarded partial tool calls
  • Rebasing onto the latest Add snapshot editing, durable compaction, and live turn control #51 head produced an identical tested tree

Risk and compatibility

  • Original tool results, JSON envelopes, event contracts, and permission evaluation stay intact
  • New artifact models/tool and ContextWindowExceeded enum value are additive; existing enum values retain their ordinals
  • No credentials, generated output, or local session data included

Token budgets remain estimates. Preview limits bound model input, not process memory or artifact/event disk usage. Artifacts follow session-storage lifetime without independent automatic deletion. Irreducible context and failed maintenance stop explicitly. Local verification ran on macOS; cross-platform CI is pending.

@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Telli and others added 2 commits November 5, 2026 18:31
…paction pinning

- Stage snapshot replacements with the target's Unix mode before writing
  content, and report a target deleted mid-staging as stale.
- Document that snapshot publication does not keep owner/ACLs/xattrs.
- write_file and edit_file take the shared semantic-write lock.
- REPL: keep the session open on non-provider prompt failures; return
  nonzero for unknown slash commands and failed custom commands; keep
  the last exit code on idle Ctrl+C.
- Compaction: check the summary budget only once compaction is needed,
  and pin the turn's original request as well as the latest correction.
- Keep provider-reported usage when the response text is empty.
- Add coverage for staging recheck, precheck cancellation, snapshot
  symlink escape, unfinished primary compaction, and cancel isolation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ontrol' into codex/runtime-resilience

# Conflicts:
#	src/SharpClaw.Code.Runtime/Context/AutomaticContextManager.cs
@Telli
Telli changed the base branch from codex/snapshot-compaction-live-control to main November 6, 2026 03:14
@Telli
Telli marked this pull request as ready for review November 6, 2026 03:14
Copilot AI balanced review requested due to automatic review settings November 6, 2026 03:14

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

# Conflicts:
#	docs/interactive-runtime.md
#	docs/tools.md
#	src/SharpClaw.Code.Agents/Abstractions/IAgentContextManager.cs
#	src/SharpClaw.Code.Agents/Internal/ProviderBackedAgentKernel.cs
#	src/SharpClaw.Code.Protocol/Serialization/ProtocolJsonContext.cs
#	src/SharpClaw.Code.Runtime/Composition/RuntimeServiceCollectionExtensions.cs
#	src/SharpClaw.Code.Runtime/Configuration/AutomaticCompactionOptions.cs
#	src/SharpClaw.Code.Runtime/Context/AutomaticContextManager.cs
#	tests/SharpClaw.Code.IntegrationTests/Runtime/InteractiveMilestoneTests.cs
#	tests/SharpClaw.Code.UnitTests/Runtime/AutomaticContextManagerTests.cs
@Telli
Telli merged commit 8911754 into main Nov 6, 2026
8 of 9 checks passed
@Telli
Telli deleted the codex/runtime-resilience branch November 6, 2026 03:18
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