refactor: migrate LLM, MCP, and tool layers to AI SDK - #226
Merged
Conversation
The root site:* scripts filtered a workspace package (@memo-code/site) that does not exist - site is a standalone pnpm project. Switch to pnpm --dir site, matching the deploy workflow. Also fill in the allowBuilds placeholders in site/pnpm-workspace.yaml that pnpm 11 rejected (native binaries for next dev/build).
Align with Codex: compact at 90% of the context window instead of 80%, so the effective context before compaction grows while the hard limit still sits at 100%.
The per-message 4k-char truncation cut most tool outputs (file contents, search results, command output) out of the compaction request, so the summary lost the actual work done - plans, decisions, and context. After compaction the model had to re-explore from scratch. Now only the budget selector limits the request: it drops the oldest messages to fit the window, and only truncates a single message when it alone exceeds the budget (tail kept). Normal transcripts reach the compaction model in full, including update_plan tool results, so the plan survives into the summary.
DeepSeek-V4 (pro/flash) supports a 1M-token context window, which the 120k default underused by 8x. Models with a smaller real window can still override via model_profiles context_window; the hard limit check and 90% auto-compact threshold scale with the configured window.
Core: add fork (spawn child sessions with filtered history), agent registry (name lookup for collaboration), communication (subagent messaging), and status (agent state) modules, wiring them through withDefaultDeps via createChildHistory. Site: restructure docs (project-guide replaces soul, drop web-console), refresh en/zh guides, components, and i18n messages.
Context window is decided by config/defaults only: remove the session history round-trip (record in session_start, parse back, restore into the session options) that let a restored session override the configured window. Provider, model, thinking, and tool permission mode restore stay.
- deps: minimatch 10.2.6, brace-expansion 5.0.9, picomatch 2.3.2, undici 6.28.0 - oauth: escape callback error text; use PowerShell for Windows URL opening - exec: 16 MiB output cap with process kill; free completed session buffers - fs: 50 MiB read cap, 10 MiB media cap - history: owner-only session file permissions
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
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.
Migrates the core LLM layer, MCP client, and tool execution onto the AI SDK, restructures
packages/coreinto domain modules, and ships TUI/CI improvements plus a security hardening pass.Highlights
b6925f6), MCP client →@ai-sdk/mcp(a160f1b,4185304), tool layer → standard AI SDK tools (ddb8ee8); dropped customToolDefinition/ToolUseBlock/API DTO types in favor of AI SDK equivalentspackages/corereorganized intofeatures//agent//toolsdomain modules; tokenizer switched from tiktoken to byte-based estimation; session kernel renamed and boundaries tightenedmemo init, builtin skill-creator, terminal-width wrapping97fefac): minimatch/brace-expansion/picomatch/undici upgrades (ReDoS, CRLF/smuggling), OAuth callback XSS escape, Windowscmd /c startcommand injection replaced with PowerShell, 16 MiB exec output cap with kill, 50/10 MiB file/media read caps, session history files now0o600Verification
pnpm buildcleanCloses #225