feat: write-side chat tools and provider wire-encoding tests#1070
Merged
Conversation
…tion) and provider wire-encoding tests
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
…ed authPolicy, decoder + cancel tests)
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.
Summary
Two phase-4 followups bundled because they share a theme (filling out the chat-tool surface area):
execute_queryandconfirm_destructive_operationasChatToolwrappers, mirroring the existing MCP versions. The connection's safe-mode dialog flow gates execution, so the user is still the final approver for any state-changing query.Write-side tools
ExecuteQueryChatTool(Tools/ExecuteQueryChatTool.swift):connection_id(or falls back to active connection),query, optionalmax_rows,timeout_seconds,database,schema.ToolConnectionMetadata.resolve, optional database/schema switch,QueryClassifier.classifyTier.ChatToolResult(isError: true)directing it to the confirm tool.MCPAuthPolicy.checkSafeModeDialog— the connection's safe-mode policy decides whether to surface a native confirmation dialog before executing.ToolQueryExecutor.executeAndLogwithprincipalLabel: "AI Chat"so query history attribution is clear.ConfirmDestructiveOperationChatTool(Tools/ConfirmDestructiveOperationChatTool.swift):confirmation_phraseto match"I understand this is irreversible"exactly.execute_query).Both are registered in
ChatToolBootstrap.register()so they ship live to all providers that emit tool calls.ChatToolArgumentDecoder.optionalInt(_:key:default:clamp:)added — needed byexecute_queryformax_rows/timeout_secondsclamping.Provider tests
Anthropic/OpenAICompatible/Geminihadprivateencoding helpers. Demoted to internal so tests can call them directly without mocking URLSession or the full streamChat pipeline.AnthropicProviderEncodingTests(6 tests): tool spec usesinput_schemasnake_case key; plain text vs typed-block array dispatch;tool_useshape;tool_resultwith and withoutis_error; empty turn drops out.OpenAICompatibleProviderEncodingTests(7 tests): tool spec wrapped intype: "function"; assistant turn withtool_callsand arguments-as-string (NOT object, per OpenAI spec);content: NSNullwhen no text;role: "tool"for results; multiple tool results expand to multiple messages.GeminiProviderEncodingTests(6 tests): assistant maps tomodelrole;functionCall.argsis a JSON object (not string, unlike OpenAI);functionResponse.nameresolves correctly even when the originatingtoolUseis two turns back; fallback totoolUseIdas name when not found; system turns skipped.Why bundle these in one PR
Both touch chat-tool plumbing. Demoting access on provider encoders is small enough not to need its own PR. Splitting would mean a write-tools PR with no test coverage and a tests-only PR — the combined story is "fill out the phase 4 surface area."
Risk
privateto internal is a tiny widening of the same-module surface area. No external module is affected (we already demotedChatToolfoundation to internal in fix: demote ChatTool foundation to internal access level #1064).Lint
swiftlint lint --strictclean across all 819 files.Test plan
execute_query. Verify the safe-mode dialog appears (if the connection has safe mode enabled).confirm_destructive_operationwith the phrase, and that the dialog still appears.xcodebuild test -only-testing:TableProTests/AnthropicProviderEncodingTestsand the OpenAI / Gemini equivalents.