Skip to content

fix(rag): RAC_ENABLE_PROTOBUF=OFF cannot compile the RAG backend - #824

Merged
sanchitmonga22 merged 1 commit into
RunanywhereAI:mainfrom
ayaangazali:fix/rag-proto-off-build
Sep 11, 2026
Merged

sanchitmonga22 merged 1 commit into
RunanywhereAI:mainfrom
ayaangazali:fix/rag-proto-off-build

Conversation

@ayaangazali

@ayaangazali ayaangazali commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Description

cmake -B build -DRAC_ENABLE_PROTOBUF=OFF does not build. It stops here:

core/src/features/rag/rac_rag_proto_abi.cpp:30:10: fatal error:
      'features/llm/llm_thinking_tags_internal.h' file not found

RAC_ENABLE_PROTOBUF is a real supported option (core/CMakeLists.txt:1417) with its own documented else() branch — "RAC_ENABLE_PROTOBUF=OFF — exported proto ABI functions use unavailable stubs" — and it is the EMSCRIPTEN default. RAC_BACKEND_RAG defaults ON, so the flag on its own is enough to reproduce.

The cause is an include on the wrong side of a guard. rac_rag_proto_abi.cpp pulls in three commons-internal headers by a path relative to the src/ root, but only two of them are inside the RAC_HAVE_PROTOBUF guard:

#include "features/llm/llm_thinking_tags_internal.h"   // line 30 — OUTSIDE the guard
...
#if defined(RAC_HAVE_PROTOBUF)
#include "foundation/rac_proto_marshal_internal.h"     // line 49 — inside
#include "infrastructure/events/sdk_event_publish.h"   // line 50 — inside

That matters because the src/ root only joins the target's include path inside the protobuf branch of core/src/features/rag/CMakeLists.txt:120:

if(RAC_PROTOBUF_RUNTIME_ENABLED OR (...))
    target_compile_definitions(rac_backend_rag PRIVATE RAC_HAVE_PROTOBUF=1)
    target_include_directories(rac_backend_rag PRIVATE
        ${CMAKE_CURRENT_SOURCE_DIR}/../../../src        # <-- only here

With protobuf off, that directory is never added and the unguarded include cannot resolve. The other two never had the problem because they sit where the include path exists.

The header's only use is model_thinking_tags_from_registry at line 497, which is itself inside the guard, so the include belongs there too. This moves that one line down beside its siblings — no new include directory, no CMake change, and nothing new compiled in either configuration.

Why CI is green today: no workflow configures RAC_ENABLE_PROTOBUF=OFF, and bindings/web/wasm/scripts/build.sh:416 passes -DRAC_ENABLE_PROTOBUF=ON explicitly, so the WASM build overrides the EMSCRIPTEN default and never hits it.

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Refactoring

Testing

  • Lint passes locally
  • Added/updated tests for changes

No test added: this is a build-configuration failure, so the build in each configuration is the check, and there is no runtime behaviour to assert. Both directions verified.

Protobuf off, which is the failure this fixes:

$ cmake -B build-noproto -DRAC_ENABLE_PROTOBUF=OFF -DRAC_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Debug
$ cmake --build build-noproto --target rac_commons -j 8
# before: core/src/features/rag/rac_rag_proto_abi.cpp:30:10: fatal error: ... file not found
# after:
[100%] Linking CXX static library librac_commons.a
[100%] Built target rac_commons
exit=0

Protobuf on, unchanged:

$ cmake -B build -DRAC_BUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Debug && cmake --build build -j 10
exit=0, 0 errors
$ ctest --test-dir build -j 10
100% tests passed out of 101

On lint: left unchecked rather than imply more than I checked. core/scripts/lint-cpp.sh wants the repo's pinned clang-format and only Apple clang-format 21 is available here, which reports pre-existing diffs in this file at lines 343/551/575/601/605/609/668 — none of them my two lines (29 and 48). I did not reformat anything.

No platform boxes ticked: commons-only, verified through the two CMake configurations and the C++ suite on macOS.

Labels

SDKs:

  • Commons - Changes to shared native code (core)

Checklist

  • Code follows project style guidelines
  • Self-review completed
  • Documentation updated (if needed)

Summary by CodeRabbit

  • Refactor
    • Improved build compatibility by limiting an internal component to configurations with protobuf support enabled.
    • No user-facing features or behavior have changed.

CI note: the red centralization is not from this diff. Its only failing step is "Swift distribution repo (runanywhere-swift) is cut at this release" — that repo is tagged 0.20.30 while this one has published v0.20.31, which scripts/release/sync-versions.sh:616 documents as failing every PR until the tag is cut. Every other step in that job, including the C++ gates, passed. Nothing to push here; the remedy is cutting the distribution repo.

Copilot AI lite review requested due to automatic review settings August 31, 2026 17:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Aug 31, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: bb31824a-dcc8-4db4-a2ee-7cb86605c417

📥 Commits

Reviewing files that changed from the base of the PR and between 488cf27 and 49349cf.

📒 Files selected for processing (1)
  • core/src/features/rag/rac_rag_proto_abi.cpp

Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

The RAG protobuf ABI source now includes llm_thinking_tags_internal.h only when RAC_HAVE_PROTOBUF is defined.

Changes

Conditional protobuf include

Layer / File(s) Summary
Restrict header to protobuf builds
core/src/features/rag/rac_rag_proto_abi.cpp
Moves the llm_thinking_tags_internal.h include into the RAC_HAVE_PROTOBUF block.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~2 minutes

Merge Risk: ⚪ Minimal · up to 49349

The targeted build fix is complete with no remaining merge-blocking risk.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the RAG build failure caused by setting RAC_ENABLE_PROTOBUF=OFF and accurately summarizes the fix.
Description check ✅ Passed The description is complete and directly supports the change. It explains the failure, root cause, implementation, testing for protobuf-on and protobuf-off configurations, platform scope, labels, chec…
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

rac_rag_proto_abi.cpp includes features/llm/llm_thinking_tags_internal.h
above the RAC_HAVE_PROTOBUF guard, but the commons src/ root only joins
rac_backend_rag's include path inside the protobuf branch of
core/src/features/rag/CMakeLists.txt. With RAC_ENABLE_PROTOBUF=OFF the
header is unreachable and the build stops on a fatal include error. Its
only use is inside the guard, so move the include next to the two
src-relative siblings that are already there.
@sanchitmonga22

Copy link
Copy Markdown
Contributor

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Sep 11, 2026

Copy link
Copy Markdown
✅ Action performed

Full review finished.

@sanchitmonga22 sanchitmonga22 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks a lot for this, @ayaangazali! This fixes the RAG backend failing to compile with RAC_ENABLE_PROTOBUF=OFF — it moves the features/llm/llm_thinking_tags_internal.h include inside the existing RAC_HAVE_PROTOBUF guard, right next to its only caller in this file.

Checked: CodeRabbit reviewed the latest commit · CI green · built and linted locally merged into main (C++ commons RAG backend, both protobuf ON and OFF) · two independent code reviews.

Follow-ups, not blocking: #902 (CI never exercises the protobuf-OFF RAG build) — you're welcome to pick it up.

Merging now — really appreciate the contribution!

Reviewed with help from Claude Code and Codex.

@sanchitmonga22
sanchitmonga22 merged commit 146d8f2 into RunanywhereAI:main Sep 11, 2026
36 checks passed
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.

3 participants