Repository navigation
feat(core): E4.5 real provider tool-calling - #28
Merged
Merged
Conversation
- Tool::spec() supplies JSON Schema parameters per tool; registry serializes specs() into the OpenAI tools array (sorted, deterministic) - OpenAiProvider: with_tool_specs(), ChatRequest.tools, ChatMessage tool_calls/tool_call_id, response parsing emits ProviderOutput::ToolCall - flatten transcript: Intent entries become assistant tool_calls messages, ToolResult entries become tool-role messages with tool_call_id - specs for cora_search, uteke_search, read_file, gh (validated live: model now sends correct arguments) - CLI wires registry.specs() into provider for run and resume Closes #27
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
- tool_result/error content now passes through scrub() before the wire,
extending E11 redaction to tool outputs that may echo the API key
- malformed tool_calls arguments are surfaced to the model as a
parse-error result instead of silently running with {}
- new ProviderOutput::InvalidToolArgs variant: parse failures in tool_calls.arguments no longer produce a synthetic ToolCall input - turn loop records the intent and settles it as an error sandwich WITHOUT executing the tool — the model sees the parse error and can retry with well-formed JSON
| e.payload | ||
| .get("output") | ||
| .cloned() | ||
| .unwrap_or_else(|| json!({ "ok": true })) |
Turn-level errors (budget exhausted, invalid tool arguments) have no parent intent; emitting them as tool messages with a null tool_call_id makes the OpenAI API reject the next request with 400.
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.
What
Tool::spec()method: each tool supplies its own JSON Schemaparameters(cora_search, uteke_search, read_file, gh)ToolRegistry::specs(): serializes all specs into the OpenAItoolsarray, sorted by name for deterministic payloadsOpenAiProvider::with_tool_specs(): stores tool definitions sent with every/chat/completionsrequestChatRequest.tools+ChatMessagetool_calls/tool_call_id: full wire format supportchoices[].message.tool_calls→ProviderOutput::ToolCall(previously silently dropped)Intententries → assistant messages withtool_calls;ToolResultentries →tool-role messages withtool_call_id(previously filtered out — the model never saw tool output)run/resumepassregistry.specs()to the providerWhy
Tole's turn loop, state machine, and tool registry were complete, but the OpenAI wire layer never sent tool definitions and never returned tool results to the model. Live smoke test confirmed the model could not call any tool. E4.5 closes this gap — the agent loop now works end-to-end against a real provider.
Testing
cargo test --workspace: 100/100 pass (4 new tests: spec serialization, tool_calls parsing, intent flatten, tool_result flatten)cargo clippy --workspace --all-targets: 0 warningscora review --diff-file: clean (0 issues)cora_search→ durable log showsintent_4(tool: cora_search, {"query":"loop guard fingerprint"}) →tool_resultok → model replies DONE. Full tool-calling loop verified against real provider.Closes #27