feat: confucius-aligned agent stack — economy mode, session memory, context pruning, self-correction - #35
Merged
Conversation
|
Hey @Copilot! 👋 I'll go through the changes and help you out with an automated review! 🔍 Starting the review now... |
Copilot
AI
changed the title
[WIP] Add Confucius-aligned agent stack with security hardening
feat: confucius-aligned agent stack — economy mode, session memory, context pruning, self-correction
Mar 17, 2026
iotserver24
marked this pull request as ready for review
March 17, 2026 02:13
There was a problem hiding this comment.
Copilot wasn't able to review any files in this pull request.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
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.
Adds a layered set of cost-control and quality improvements to the XibeCode agent: economy mode (iteration caps + cheaper planning model), session memory, context pruning, plan-first execution, self-correction retries for
run-pr, and security utilities for path/URL validation.Description
Economy Mode & Multi-Model Routing
--cost-mode economyCLI flag (andconfig --set-cost-mode) caps agent iterations and routes planning steps to a cheaper model while reserving the full model for execution turns.economyMaxTokensconfig key exists; note:max_tokensinagent.tsis still hard-coded (8192/16000) — economy mode today reduces iterations, not per-request token budget.Session Memory & Context Pruning
context-pruner.tsscores and selects the most relevant files before building the context window, replacing coarse file inclusion.Security Utilities (
src/utils/safety.ts)sanitizePath(workingDir, filePath)— resolves and validates paths stay inside the working directory; rejects traversal attempts.sanitizeUrl(url)— blocks non-http(s) protocols and private/localhost destinations (SSRF mitigation forfetch_url).Self-Correction Loop (
run-pr)run-prretries after test failures up to a configurable limit before giving up, allowing the agent to fix its own mistakes before surfacing an error.Meta-Tool Synthesis (
synthesize_tool)synthesize_tool. Known gap: synthesized tool names are not inTOOL_CATEGORIES, soisToolAllowed()rejects them before dispatch — needs permission-layer fix before this is functional.Type of Change
Related Issues
Testing
pnpm test)pnpm test:e2e)pnpm build)Checklist
Screenshots (if applicable)
💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.