Skip to content

Keep broad project roots from overflowing model context - #80

Merged
DevMando merged 1 commit into
mainfrom
feat/maf-workflow-planner
Aug 30, 2026
Merged

Keep broad project roots from overflowing model context#80
DevMando merged 1 commit into
mainfrom
feat/maf-workflow-planner

Conversation

@DevMando

Copy link
Copy Markdown
Owner

What changed

This closes a context-overflow path found during live CLI testing with a broad project root.

  • Gives list_all_project_files an optional directory scope and tells the model to use it when the user references a directory such as @MandoCode/.
  • Carries an explicit scope instruction with directory references so later reads keep the directory prefix instead of falling back to the project root.
  • Caps recursive file listings and points the model toward a narrower directory or glob when more detail is needed.
  • Truncates any oversized tool result before it is added to conversation history. Previously, the budget stopped the next call but could not prevent one huge result from overflowing the current request.

Why

With the project root set to a large directory, asking about @MandoCode/ could make the model miss the directory prefix, list every file under the root, and retry the same oversized payload after compaction. In the reproduced case, the provider rejected the request for exceeding its context window by roughly one million tokens.

The fix is layered so a model mistake is still safe: directory references steer toward the right scope, listings have their own cap, and middleware enforces the configured result budget before delivery.

Validation

  • 623 tests passed on .NET 10
  • 623 tests passed on .NET 8
  • Added regressions for directory-scoped listings, bounded large-tree output, @directory scope instructions, and single-result budget enforcement

No package, tag, or release is published by this PR.

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