fix(agent): render tool parameters deterministically - #721
Conversation
|
✅ OpenCodeReview: Review complete: 0 finding(s) across 1 selected item(s). |
|
Thanks for this thorough contribution — the analysis in the PR description is well-written and the test coverage is solid. I'd like to suggest two refinements before merging: 1. Preserve original parameter order from Tool authors intentionally order parameters by importance (e.g. A possible approach: keep the raw JSON bytes available at render time and walk the 2. Consider using Our Let me know if you'd like to discuss the design direction for preserving JSON key order — happy to help scope that out. |
lizhengfeng101
left a comment
There was a problem hiding this comment.
@Anon2Tokyo I'd like to suggest two refinements before merging
|
@lizhengfeng101 Thanks for the suggestions. I updated the implementation to preserve the original |
Description
Render tool parameters in a deterministic order when building tool descriptions for the plan-stage system prompt.
formatToolDefspreviously ranged over the JSON schemapropertiesmap directly, so the rendered parameter order could vary across runs. Sorting parameter names before rendering keeps the generated prompt byte-stable for the same tool definitions, improving prefix/prompt cache reproducibility without changing prompt semantics.Type of Change
How Has This Been Tested?
make testpasses locallygo test ./internal/agentgo test -race ./internal/agentgo vet ./...make buildgofmt -l internal/agent/agent.go internal/agent/agent_test.goproduced no outputChecklist
go fmt,go vet)Focused agent tests pass locally, including race detection. No documentation update is needed because this does not change user-facing behavior. I will follow the CLA bot instructions if required.
Related Issues
Closes #719