feat(claude-code): add context offloading for large context injections#594
Merged
zbigniewsobiecki merged 2 commits intodevfrom Mar 1, 2026
Merged
Conversation
Replace the ad-hoc capability system with a unified capability-centric
architecture where integrations provide capabilities and capabilities
provide tools.
Key changes:
**New capability system (`src/agents/capabilities/`):**
- Add capability registry mapping capabilities to gadgets and SDK tools
- Add resolver functions for deriving integrations from capabilities
- Add `resolveEffectiveCapabilities()` for runtime optional capability filtering
- Add `createIntegrationChecker()` factory for project integration lookups
- Add `generateUnavailableCapabilitiesNote()` for system prompt injection
**Schema changes (`src/agents/definitions/schema.ts`):**
- Replace boolean capability flags with typed capability arrays
- `capabilities: { required: Capability[], optional: Capability[] }`
- Remove separate `integrations` and `tools` sections (now derived)
- Remove `gadgetBuilder` strategy (replaced by capability-based building)
**Agent definition updates (all YAML files):**
- Migrate all 10 agent definitions to new capability format
- debug.yaml: Remove fs:write (read-only analysis agent)
- respond-to-ci.yaml: Add pm:checklist to optional capabilities
**Runtime improvements:**
- Wire `IntegrationChecker` through profiles.ts and llmist backend
- Optional capabilities filtered by actual project integration availability
- Fix: Throw on missing gadget constructors (was silently skipped)
- Fix: Only fall back to full access for "not found" errors in legacy shim
- Fix: Pass correct agentType to preExecute hooks
- Add validation warning for missing tools in filterToolManifests
**Test coverage:**
- Add comprehensive resolver.test.ts for capability resolution functions
- Update all affected tests for new capability format
- Add mock for createIntegrationChecker in llmist tests
This refactoring:
- Eliminates redundancy between schema and runtime capability logic
- Makes integration requirements derivable from capability declarations
- Provides architectural safety (tools don't exist if cap not enabled)
- Enables graceful degradation for optional integrations
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When context injections exceed the inline threshold (8k tokens), offload them to files under .cascade/context/ and instruct Claude to read them on-demand using its Read tool. This prevents prompt size issues with large PR diffs or file contents. Key changes: - Add contextFiles.ts module with offloadLargeContext, cleanupContextFiles - Add CONTEXT_OFFLOAD_CONFIG with inlineThreshold, contextDir, enabled - Update buildTaskPrompt to be async and handle context offloading - Auto-cleanup context files after agent execution via try/finally - Slugify filenames with index suffix to prevent collisions - Use POSIX paths for cross-platform consistency in instructions Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
.cascade/context/and instruct Claude to read them on-demand using its Read toolTest plan
offloadLargeContext- small context inline, large context offloadedcleanupContextFiles- removes directory, handles missing directorybuildInlineContextSection- formattingbuildTaskPromptintegration - inline small, offload large🤖 Generated with Claude Code