Skip to content

Update web-tool-prompt.ts#189

Open
sharkfee wants to merge 2 commits intolinuxhsj:mainfrom
sharkfee:patch-1
Open

Update web-tool-prompt.ts#189
sharkfee wants to merge 2 commits intolinuxhsj:mainfrom
sharkfee:patch-1

Conversation

@sharkfee
Copy link
Copy Markdown

@sharkfee sharkfee commented Apr 8, 2026

由于3.28的bug,每次 /NEW命令,不会注入系统提示词,我在这里加了一段提示,让AI去读取AGENTS.md,AI再根据AGENTS.md的要求去读取其他配置文件。解决失忆的问题。不太懂代码,所以硬编码了我自己配置文件的目录。

Summary

Describe the problem and fix in 2–5 bullets:

  • Problem:
  • Why it matters:
  • What changed:
  • What did NOT change (scope boundary):

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

  • Closes #
  • Related #

User-visible / Behavior Changes

List user-visible changes (including defaults/config).
If none, write None.

Security Impact (required)

  • New permissions/capabilities? (Yes/No)
  • Secrets/tokens handling changed? (Yes/No)
  • New/changed network calls? (Yes/No)
  • Command/tool execution surface changed? (Yes/No)
  • Data access scope changed? (Yes/No)
  • If any Yes, explain risk + mitigation:

Repro + Verification

Environment

  • OS:
  • Runtime/container:
  • Model/provider:
  • Integration/channel (if any):
  • Relevant config (redacted):

Steps

Expected

Actual

Evidence

Attach at least one:

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Human Verification (required)

What you personally verified (not just CI), and how:

  • Verified scenarios:
  • Edge cases checked:
  • What you did not verify:

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

If a bot review conversation is addressed by this PR, resolve that conversation yourself. Do not leave bot review conversation cleanup for maintainers.

Compatibility / Migration

  • Backward compatible? (Yes/No)
  • Config/env changes? (Yes/No)
  • Migration needed? (Yes/No)
  • If yes, exact upgrade steps:

Failure Recovery (if this breaks)

  • How to disable/revert this change quickly:
  • Files/config to restore:
  • Known bad symptoms reviewers should watch for:

Risks and Mitigations

List only real risks for this PR. Add/remove entries as needed. If none, write None.

  • Risk:
    • Mitigation:

Summary by CodeRabbit

  • 功能改进
    • 优化工具调用提示模板,要求模型以精确的 XML <tool_call> 包装输出,取代此前的 code-block JSON 格式,提升可解析性。
    • 更新中/英示例与说明,明确内嵌 JSON 需包含 "name" 与 "arguments",并约束仅返回 XML 块,减少额外文本。

由于3.28的bug,每次 /NEW命令,不会注入系统提示词,我在这里加了一段提示,让AI去读取AGENTS.md,AI再根据AGENTS.md的要求去读取其他配置文件。解决失忆的问题。不太懂代码,所以硬编码了我自己配置文件的目录。
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 8, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 0e7acaf9-8a75-4628-af7c-dbc1ef7f678a

📥 Commits

Reviewing files that changed from the base of the PR and between dbb583e and 2c8e120.

📒 Files selected for processing (1)
  • src/zero-token/tool-calling/web-tool-prompt.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/zero-token/tool-calling/web-tool-prompt.ts

📝 Walkthrough

Walkthrough

将工具调用提示模板从要求模型输出 tool_json 代码块改为必须精确的 XML <tool_call> 包装,示例负载与中英指令更新,内部 JSON 结构现在要求 {"name": ..., "arguments": ...};导出签名不变,注释亦更新为参考 XML。

Changes

Cohort / File(s) Summary
工具调用提示模板
src/zero-token/tool-calling/web-tool-prompt.ts
将输出格式从 tool_json 代码块更改为 XML <tool_call>,更新示例负载与中英文指示,内部 JSON 字段从 {"tool","parameters"} 改为 {"name","arguments"},注释和响应约束改为针对 XML(导出签名未变)。

代码审查工作量估计

🎯 3 (Moderate) | ⏱️ ~20 minutes

已更新的现有节

概览

此次更改修改了工具调用提示模板,要求模型输出采用 XML <tool_call> 格式而非 tool_json 代码块。示例负载和英文/严格英文/中文指示已更新,要求内部 JSON 包含 "name""arguments"。响应约束从"仅回复 tool_json 块"改为"仅回复 XML tool_call 块"。

变更内容

群组 / 文件 摘要
工具调用提示模板
src/zero-token/tool-calling/web-tool-prompt.ts
更新工具调用提示模板,将输出格式从 tool_json 代码块改为 XML <tool_call> 格式。修改 JSON 结构要求、响应约束文本,并在中文模板中添加配置文件读取指令。注释描述相应更新以反映 XML 而非 JSON 结构。

代码审查工作量估计

🎯 3 (Moderate) | ⏱️ ~20 分钟

兔子的贺诗

🐰 新模版换新衣,XML 闪亮又精致,
名称与参数在列里,格式严谨少歧义,
小兔跳跃送祝福,编码旅途共欢喜! 🎉

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Description check ⚠️ Warning PR描述存在严重缺陷:用中文描述问题但模板为英文;关键字段(问题描述、影响范围、安全影响、验证步骤、证据等)大部分未填或空白;存在描述与代码摘要的矛盾。 需补充完整的英文描述,包括:详细问题陈述、变更范围、安全影响评估、验证步骤、测试证据,并解明prompt修改与工具调用格式变更之间的关系。
Title check ❓ Inconclusive PR标题过于宽泛模糊,仅说'Update web-tool-prompt.ts',未能清晰传达主要变更意图(修复系统提示词注入问题或调整工具调用格式)。 建议更新标题为更具体的描述,如'Fix system prompt injection in /NEW command'或'Update tool-call format to XML wrapper',以准确反映主要变更。
✅ Passed checks (1 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 and usage tips.

Copy link
Copy Markdown

@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: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/zero-token/tool-calling/web-tool-prompt.ts`:
- Around line 47-49: The Chinese template's JSON example in web-tool-prompt.ts
is inconsistent with the required OpenAI format (it shows {"number":"5"} but
parser expects {"name":"...","arguments":{...}}); update the Chinese example
(the <tool_call id="call_001" name="plus_one"> sample) to the full format
matching the English template (e.g.
{"name":"plus_one","arguments":{"number":"5"}}) so web-tool-parser.ts's extract
logic (lines ~84-89) can correctly parse tool calls.
- Line 54: Remove the hardcoded user-specific path
"~/.openclaw-zero/workspace/AGENTS.md" from the prompt template in
web-tool-prompt.ts (the prompt string/variable or builder that injects
tool-calling instructions); instead either delete the line from the template or
replace it with a configurable placeholder and accept the actual path via a
config/parameter (e.g., an injected options value or agentConfigPath passed into
the function that builds the prompt). Update the function/variable that
constructs the prompt so it no longer embeds user-specific filesystem locations
and document the new config placeholder/parameter in the function signature or
exported config interface.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 309a580e-15c8-4f71-8d78-2534721f3b17

📥 Commits

Reviewing files that changed from the base of the PR and between a62ccbe and dbb583e.

📒 Files selected for processing (1)
  • src/zero-token/tool-calling/web-tool-prompt.ts

Update tool call format to include 'name' and 'arguments' in JSON.
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