Skip to content

chore(upstream): backport Grok/Qwen/repocache fixes (#5748, #5752, #5772) - #12

Merged
wujunyi792 merged 3 commits into
mainfrom
chore/backport-agent-fixes
Jul 22, 2026
Merged

wujunyi792 merged 3 commits into
mainfrom
chore/backport-agent-fixes

Conversation

@wujunyi792

@wujunyi792 wujunyi792 commented Jul 22, 2026 •

Copy link
Copy Markdown
Member

Three clean, low-risk upstream fixes squarely in the fork's agent/daemon core (cherry-picked with -x).

  • #5748 fix(agent) — parse Grok ACP token usage from session/prompt _meta (MUL-5137).
  • #5752 fix(agent) — inject --yolo in Qwen headless runs so shell/edit/write tools are available (MUL-5141).
  • #5772 fix(repocache) — repair promisor config on isolated checkouts of a partial cache (relevant to the fork's worktree work).

go build/vet clean; Grok/Qwen agent tests and daemon repocache/worktree tests pass (the load-flaky CodexExecute ACP-subprocess family excluded — unrelated).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • 新功能

    • Qwen Code 在无人值守运行时自动启用安全执行模式,并强化关键权限参数管理。
    • 支持从更多响应格式中准确读取 AI 使用量与令牌统计。
  • 问题修复

    • 改善部分 Git 仓库缓存创建和复用时的文件检出,确保工作区内容完整可用。
  • 文档

    • 补充 Qwen Code 的无人值守运行、沙箱启用及工具排除配置说明。
    • 更新隔离式检出与部分克隆缓存的行为说明。

chenow9 and others added 3 commits July 22, 2026 19:49
…_meta (#5748)

* fix(agent): parse Grok ACP token usage from session/prompt _meta

Grok Build places per-turn metering under result._meta (and
_meta.usage), not the top-level ACP usage field. Multica's shared
parser only read result.usage, so Grok tasks recorded empty token
usage and cost dashboards stayed at zero.

Fall back to _meta.usage (then flat _meta counters) when top-level
usage is absent. Prefer standard top-level usage when both are
present. Update the Grok fake ACP fixture and add regression tests
against the live 0.2.x payload shape.

* test(agent): cover zero ACP usage meta fallback

Co-authored-by: multica-agent <github@multica.ai>

---------

Co-authored-by: Eve <eve@multica-ai.local>
Co-authored-by: multica-agent <github@multica.ai>
(cherry picked from commit d804ded)
…it/write tools are available (#5752)

* fix(agent): inject --yolo in Qwen headless runs so shell/edit/write tools are available (Fixes #5743)

Qwen Code's non-interactive mode (`-p … --output-format stream-json`) uses a
fail-closed approval policy: it silently drops `run_shell_command`, `edit`,
`write_file`, and `monitor` from the tool registry unless bypass mode is
active.  Every other Multica-supported coding adapter already injects its
equivalent permission flag as a daemon-owned argument (e.g. Claude uses
`--permission-mode bypassPermissions`, Grok uses `--always-approve`, Qoder
uses `--yolo --acp`).  Qwen was the only exception.

Changes:
- `buildQwenArgs`: append `--yolo` after the protocol flags and before any
  custom args so headless daemon runs always receive the full tool set.
- `qwenBlockedArgs`: add `--yolo`, `-y`, `--approval-mode`, and
  `--allowed-tools` as daemon-owned flags that are stripped from custom_args.
  This prevents users from accidentally or intentionally disabling bypass mode
  or narrowing the allowed tool set via per-agent settings.  `--exclude-tools`
  is intentionally left unblocked so users can still hard-deny specific tools.
- `TestBuildQwenArgsKeepsProtocolManaged`: extend with the new blocked flags
  and assert daemon-owned `--yolo` appears exactly once.
- `TestBuildQwenArgsYoloAlwaysPresent`: new test asserting `--yolo` is present
  even when `ExecOptions` carries no custom args.

* fix(agent): correct Qwen permission args and docs

Co-authored-by: multica-agent <github@multica.ai>

---------

Co-authored-by: Eve <eve@multica-ai.local>
Co-authored-by: multica-agent <github@multica.ai>
(cherry picked from commit 3171e66)
…tial cache (#5772)

The isolated-checkout path used by Linux Codex builds a task-local
repository with `git clone --local` from the workspace's bare cache.
That command has two properties that combine badly when the cache is a
partial clone: it does not carry the promisor remote configuration
across, and it does not treat an incomplete source object store as an
error. The result is a checkout that exits 0 with every tracked file
reported as deleted, so an agent starts work in what looks like a
repository someone emptied.

Swap origin to the real remote and restore
`remote.origin.promisor` / `remote.origin.partialclonefilter` before the
first checkout, so git can lazily fetch the blobs it needs. Do the same
on the reuse path, where a workdir created against a complete cache can
later be resumed against a partial one.

No cache is created as a partial clone today, so this changes nothing
for existing installs; it is a prerequisite for the on-demand clone mode
in MUL-4983 and hardens a path that fails silently rather than loudly.

Co-authored-by: Bohan-J <bohan@devv.ai>
Co-authored-by: multica-agent <github@multica.ai>
(cherry picked from commit 1157d3f)
@wujunyi792
wujunyi792 merged commit c88d0f4 into main Jul 22, 2026
6 of 7 checks passed
@wujunyi792
wujunyi792 deleted the chore/backport-agent-fixes branch July 22, 2026 11:53
@coderabbitai

coderabbitai Bot commented Jul 22, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e63166dd-4e48-44f8-a0c8-efb42524dc16

📥 Commits

Reviewing files that changed from the base of the PR and between a7e8e46 and e16bd78.

📒 Files selected for processing (10)
  • apps/docs/content/docs/install-agent-runtime.mdx
  • apps/docs/content/docs/providers.mdx
  • server/internal/daemon/repocache/cache.go
  • server/internal/daemon/repocache/partial_clone_test.go
  • server/internal/service/builtin_skills/multica-runtimes-and-repos/references/runtimes-and-repos-source-map.md
  • server/pkg/agent/grok_test.go
  • server/pkg/agent/hermes.go
  • server/pkg/agent/hermes_test.go
  • server/pkg/agent/qwen.go
  • server/pkg/agent/qwen_test.go

Walkthrough

本次变更修复 partial clone 隔离检出,强化 Qwen 无人值守参数控制,并扩展 ACP token 用量解析对 _meta 格式的支持,同时新增相关测试和文档说明。

Changes

Partial clone 隔离检出

Layer / File(s) Summary
Partial clone 配置恢复与检出顺序
server/internal/daemon/repocache/cache.go
识别 partial clone 并恢复 promisor 配置;真实 origin 在首次 detached checkout 前完成设置。
Partial clone 场景验证
server/internal/daemon/repocache/partial_clone_test.go, server/internal/service/builtin_skills/.../runtimes-and-repos-source-map.md
新增真实 Git 场景测试,覆盖创建、复用、linked-worktree、文件完整性和 partial clone 判定,并更新相关说明。

Qwen 守护进程参数

Layer / File(s) Summary
Qwen 参数策略与文档
server/pkg/agent/qwen.go, apps/docs/content/docs/*.mdx
强制追加 --yolo,过滤用户提供的权限控制参数,并补充沙箱和工具限制说明。
Qwen 参数过滤测试
server/pkg/agent/qwen_test.go
验证工具参数保留、受控参数过滤以及 --yolo 仅出现一次。

ACP 用量解析

Layer / File(s) Summary
ACP 用量回退解析
server/pkg/agent/hermes.go
当顶层 usage 没有有效计数时,从 _meta.usage 或扁平 _meta 字段读取 token 用量。
ACP 用量响应测试
server/pkg/agent/grok_test.go, server/pkg/agent/hermes_test.go
更新 Grok 模拟响应,并覆盖来源优先级与零值回退。

Estimated code review effort: 4 (Complex) | ~45 minutes

Suggested reviewers: multica-eve

Poem

兔子蹦蹦看缓存,
缺失的 blob 有了门。
Qwen 戴上 yolo 帽,
用量藏在 meta 中报。
测试齐唱萝卜歌,
代码跑得稳又妥。

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/backport-agent-fixes

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.12.2)

level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies"


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.

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.

4 participants