fix(commons): report tool-calling output allocation failures - #740
fix(commons): report tool-calling output allocation failures#740shubhamsinnh wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan includes up to 10 reviews per rolling hour; 8 remain after this review. 📝 WalkthroughWalkthroughThe LLM tool-calling helpers now detect allocation failures when creating fallback clean text, empty prompts, and empty tool-definition JSON. They return ChangesLLM allocation error handling
Estimated code review effort: 1 (Trivial) | ~5 minutes Merge Risk: ⚪ Minimal · up to This localized change makes four allocation-failure paths return an out-of-memory error instead of reporting success with null output; no actionable merge-blocking risk remains after normal checks and review. Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
The four public paths look right. The same shape survives in the Two are sharper. At 1373 and 1575 the allocation is Line numbers are against the base, all below your first hunk. Read only, no C++ build here. |
Description
Several tool-calling output paths in
tool_calling.cppreturnedRAC_SUCCESSeven when their required output allocation failed, while the matching non-empty paths already returnRAC_ERROR_OUT_OF_MEMORY. This makes allocation failures indistinguishable from success:rac_tool_call_parse_with_format— the parse-fallback path returnedRAC_SUCCESSwith aNULLclean_textwhen the fallbackmallocfailed.rac_tool_call_format_prompt_with_format— the empty-definitions path returnedRAC_SUCCESSwith aNULLprompt whenmalloc(1)failed.rac_tool_call_format_prompt_json_with_format— the empty-tools JSON path returnedRAC_SUCCESSwith aNULLprompt whenmalloc(1)failed.rac_tool_call_definitions_to_json— the empty-definitions path returnedRAC_SUCCESSwith aNULLoutput whenmalloc(3)(the"[]"literal) failed.Each now returns
RAC_ERROR_OUT_OF_MEMORYon allocation failure, matching the existing non-empty-path behavior. No other behavior changes.Type of Change
Testing
Local:
git diff --check— clean.g++ -std=c++20 -fsyntax-only -I core/include -I core/src -I <scratch-nlohmann> core/src/features/llm/tool_calling.cpp— exit 0 (nlohmann single header downloaded locally;RAC_HAVE_PROTOBUFnot defined, so the protobuf-generatedtool_calling.pb.hsection is skipped).core/scripts/lint-cpp.sh(clang-format) could not run on this Windows host; thepr-build.ymlnative build is the authoritative gate.Platform-Specific Testing (check all that apply)
Swift SDK / iOS Sample:
Kotlin SDK / Android Sample:
Flutter SDK / Flutter Sample:
React Native SDK / React Native Sample:
Web SDK / Web Sample:
Labels
Please add the appropriate label(s):
SDKs:
Swift SDK- Changes to Swift SDK (bindings/swift)Kotlin SDK- Changes to Kotlin SDK (bindings/kotlin)Flutter SDK- Changes to Flutter SDK (bindings/flutter)React Native SDK- Changes to React Native SDK (bindings/react-native)Web SDK- Changes to Web SDK (bindings/web)Commons- Changes to shared native code (core)Sample Apps:
Flutter Sample- Changes to Flutter example app (bindings/flutter/example)React Native Sample- Changes to React Native example app (bindings/react-native/example)Minimal Examples- Changes to an in-repo SDK harness (bindings/{swift,kotlin,web}/example)The iOS, Android, Web, and Electron consumer apps live in their own
repositories (
RunanywhereAI/runanywhere-{ios,android,web,electron}) — openthose PRs there.
Checklist
Screenshots
Attach relevant UI screenshots for changes (if applicable):
Summary by CodeRabbit