Skip to content

default tool type to "function" (sometimes APIs omit this from deltas)#2662

Merged
sawka merged 1 commit intomainfrom
sawka/fix-type-tools
Dec 11, 2025
Merged

default tool type to "function" (sometimes APIs omit this from deltas)#2662
sawka merged 1 commit intomainfrom
sawka/fix-type-tools

Conversation

@sawka
Copy link
Member

@sawka sawka commented Dec 11, 2025

No description provided.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 11, 2025

Walkthrough

In the processChatStream function within the OpenAI chat backend, a ToolCall struct that is appended to toolCallsInProgress is now initialized with the Type field explicitly set to "function" rather than being initialized as an empty struct. This ensures newly created entries have a default type value established at initialization time.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

  • Single-line change in one function with straightforward struct field initialization
  • No logic, control-flow, or exported signature modifications
  • No broader API surface changes affecting other components

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Description check ❓ Inconclusive No pull request description was provided by the author, making it impossible to assess whether any description content is related to the changeset. Add a pull request description that explains the purpose, context, and rationale for defaulting tool type to 'function' in ToolCall initialization.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: defaulting the tool type to 'function' in newly created ToolCall entries, with context about why (API omissions).
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch sawka/fix-type-tools

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
pkg/aiusechat/openaichat/openaichat-backend.go (1)

167-189: Defaulting ToolCall.Type to "function" is a clean, targeted fix

Initializing new ToolCall entries with Type: "function" aligns with the struct’s documented default and ensures Type is non‑empty when the upstream delta omits it, while still allowing explicit tcDelta.Type values to override it. If you already have (or later add) a shared constant for the "function" type, consider using it here to keep things DRY, but the current change is correct and safe as-is.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 440be99 and 0bbf8a0.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (1)
  • pkg/aiusechat/openaichat/openaichat-backend.go (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: sawka
Repo: wavetermdev/waveterm PR: 2433
File: pkg/aiusechat/tools_readfile.go:197-197
Timestamp: 2025-10-15T03:21:02.229Z
Learning: In Wave Terminal's AI tool definitions (pkg/aiusechat/tools_*.go), the Description field should not mention approval requirements even when ToolApproval returns ApprovalNeedsApproval. This prevents the LLM from asking users for approval before calling the tool, avoiding redundant double-approval prompts since the runtime will enforce approval anyway.
📚 Learning: 2025-10-15T03:21:02.229Z
Learnt from: sawka
Repo: wavetermdev/waveterm PR: 2433
File: pkg/aiusechat/tools_readfile.go:197-197
Timestamp: 2025-10-15T03:21:02.229Z
Learning: In Wave Terminal's AI tool definitions (pkg/aiusechat/tools_*.go), the Description field should not mention approval requirements even when ToolApproval returns ApprovalNeedsApproval. This prevents the LLM from asking users for approval before calling the tool, avoiding redundant double-approval prompts since the runtime will enforce approval anyway.

Applied to files:

  • pkg/aiusechat/openaichat/openaichat-backend.go
🧬 Code graph analysis (1)
pkg/aiusechat/openaichat/openaichat-backend.go (1)
pkg/aiusechat/openaichat/openaichat-types.go (1)
  • ToolCall (63-68)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Analyze (go)
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Build for TestDriver.ai

@sawka sawka merged commit 96b397f into main Dec 11, 2025
6 checks passed
@sawka sawka deleted the sawka/fix-type-tools branch December 11, 2025 02:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant