Fix/anthropic native tools#39
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughSummary by CodeRabbit
WalkthroughWriteTool now rejects empty write content and the write schema uses the ChangesWrite Tool Content Validation and Testing
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 2❌ Failed checks (2 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #39 +/- ##
==========================================
+ Coverage 60.13% 60.16% +0.02%
==========================================
Files 168 168
Lines 16663 16665 +2
==========================================
+ Hits 10021 10027 +6
+ Misses 5632 5628 -4
Partials 1010 1010
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
internal/assistant/anthropic_internal_test.go (1)
81-103: ⚡ Quick winPrefer table-driven coverage for tool-name mapping cases.
These mapping checks are core behavior and will be easier to extend/maintain as table-driven cases in one test function.
As per coding guidelines, "
**/*_test.go: Prefer table-driven tests for core behavior and regression tests for terminal rendering bugs".🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/assistant/anthropic_internal_test.go` around lines 81 - 103, Combine the two existing tests into a single table-driven test that exercises the mapping between Claude/Anthropic tool names and local tool names: create a TestAnthropicToolNameMapping test that defines cases (e.g., payload-encoding case and tool-call mapping case) with fields for input (use testCompletionRequestAuth/API key or testAnthropicToolUseID, action like "Write"/"Read", and args) and expected outputs (expected encoded tool names or call.Name and call.Arguments); iterate cases with t.Run and t.Parallel(), invoking anthropicPayload or anthropicToolCall as appropriate, and assert expected name mappings (jsonWriteToolName/jsonReadToolName vs anthropicReadToolName) and argument passthrough using the same helpers encodeTestJSON and assert.Equal/assert.Contains as before so coverage is equivalent but now table-driven for easier extension.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/tool/registry_test.go`:
- Around line 69-80: Update the test
TestRegistry_ExecuteJSONRejectsEmptyWriteContent to be table-driven and include
a whitespace-only content case (e.g. " \n\t") in addition to the empty string;
for each table entry call registry.ExecuteJSON(context.Background(), "write",
payload) and assert an error whose message contains "write content is required"
to ensure the trim-based validation in Write is covered. Use the existing
registry := tool.NewRegistry(t.TempDir()) setup and json.Marshal per case to
build payloads and iterate assertions.
---
Nitpick comments:
In `@internal/assistant/anthropic_internal_test.go`:
- Around line 81-103: Combine the two existing tests into a single table-driven
test that exercises the mapping between Claude/Anthropic tool names and local
tool names: create a TestAnthropicToolNameMapping test that defines cases (e.g.,
payload-encoding case and tool-call mapping case) with fields for input (use
testCompletionRequestAuth/API key or testAnthropicToolUseID, action like
"Write"/"Read", and args) and expected outputs (expected encoded tool names or
call.Name and call.Arguments); iterate cases with t.Run and t.Parallel(),
invoking anthropicPayload or anthropicToolCall as appropriate, and assert
expected name mappings (jsonWriteToolName/jsonReadToolName vs
anthropicReadToolName) and argument passthrough using the same helpers
encodeTestJSON and assert.Equal/assert.Contains as before so coverage is
equivalent but now table-driven for easier extension.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 01337f9a-ace1-4e77-a0d3-ba482c0c2c51
📒 Files selected for processing (4)
internal/assistant/anthropic_internal_test.gointernal/assistant/tool_schema.gointernal/tool/registry_test.gointernal/tool/write.go
|



No description provided.