fix: resolve readline conflict, implement /reset, update model defaults in ch08#6
Open
octo-patch wants to merge 1 commit intojiji262:mainfrom
Open
Conversation
…ults in ch08 - CLI constructor now accepts optional readline.Interface to share with PermissionChecker, eliminating two competing readline instances on stdin - Add AgentLoop.reset() method that delegates to ContextManager.reset() so the /reset command actually clears conversation history - Update default model from retired claude-opus-4-5 to claude-sonnet-4-6 - Fix max_tokens from 8096 to 8192 (standard power-of-two value) - Fix mermaid diagram referencing retired claude-3-7-sonnet model
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.
Problem
Chapter 08 (
08-build-your-own.md) contains several bugs in the tutorial code that readers encounter when following along:Readline conflict —
index.tscreates areadline.Interfaceand passes it toPermissionChecker, butCLI's constructor also creates its ownreadline.Interface. Two competing readline instances both attached tostdincauses garbled input handling in interactive mode./resetcommand does nothing — The/resetcase inCLI.tsonly logs[会话已重置]but never calls any actual reset. The comment even acknowledges this as a TODO (// 这里通过事件或直接调用实现).Retired model in mermaid diagram — The final architecture diagram references
claude-3-7-sonnet, which was retired on February 19, 2026.Outdated default model — Default model is
claude-opus-4-5(legacy);claude-sonnet-4-6is the current recommended model.Unusual
max_tokensvalue —8096should be8192(standard power-of-two).Solution
readline.Interfaceparameter; when provided, it reuses the shared instance instead of creating a new one.index.tspasses the samerlto bothPermissionCheckerandCLI.AgentLoop.reset()method added, delegating toContextManager.reset(). The/resetcase inCLInow callsthis.agent.reset().claude-opus-4-5toclaude-sonnet-4-6in bothAgentLoop.tsandindex.tscode blocks.claude-3-7-sonnettoclaude-sonnet-4-6.max_tokenscorrected from8096to8192.Testing
All changes are in the tutorial markdown file. The code snippets were manually verified for correctness against the Anthropic TypeScript SDK API surface.