Tabbit
活动资源博客模型
Tabbit LogoTabbit

Tabbit — 为你工作的 AI 浏览器

主题资源

  • AI Browser Resources
  • Agentic Browser Resources
  • Browser Downloads and Install Guides
  • Browser Comparisons
  • AI Browser Alternatives
  • Browser Productivity Resources

热门指南

  • AI Browser
  • Agentic Browser Download
  • Best AI Browser 2026: Top 9 Tested & Ranked
  • AI Browser Download
  • Free AI Browser
  • Best AI Browser 2026
  • AI Browser Comparison 2026
  • AI Browser for Windows
  • AI Browser for Mac
  • Chrome Alternative 2026

活动

  • 别装了,你在《牛来》里早有原型
  • Tabbit 妙招大赛
  • KPOP SBTI 饭圈人格测试
  • Tabbit 校园共创者计划
  • fifi 的论文文献妙招精选
  • 用户问卷

关于

  • Tabbit 博客
  • 媒体报道
提示词
社区Qwen3.7 Max

Qwen3.7-Max OpenCode 缓存配置与 Agent 防暴走规则

原始来源

Reddit(r/opencodeCLI & r/QwenAI)

作者UnableStrategy, SimplyValueInvesting, DeepAd1959

原文日期2026-05-25

Tabbit 整理2026-08-20

查看原文

一句话结论

在 OpenCode CLI 或类似 Agent 中通过 OpenRouter 接入 Qwen3.7-Max 时,必须通过 @ai-sdk/alibaba 适配层显式透传上下文缓存请求头,并避免在 AGENTS.md 中使用未绑定的间接工具规则,以防单次会话 8M+ Token 暴走。

适用场景

  • 适合的任务:通过 OpenCode CLI、Claude Code 或自建 Agent 架构运行 Qwen3.7-Max 代码工程与复杂重构。

  • 不适合的任务:未配置缓存或在不可观测环境下直接让模型自主调用高频 CLI 工具。

  • 适用的模型版本:qwen/qwen-3.7-max(OpenRouter 别名)或阿里云官方 qwen3.7-max。

  • 适用的客户端、Agent 或 API:OpenCode CLI、Claude Code 兼容层、OpenRouter API、DashScope API。

  • 推荐的推理档位和参数:系统提示词置顶固定前缀以实现 Prompt Caching,关闭开放式非严格匹配指令。

可直接使用的内容

1. OpenCode CLI 启用 OpenRouter 上下文缓存的 opencode.json 配置

{
  "provider": {
    "openrouter-cached": {
      "npm": "@ai-sdk/alibaba",
      "name": "OpenRouter (Cached)",
      "options": {
        "baseURL": "https://openrouter.ai/api/v1",
        "apiKey": "YOUR_OPENROUTER_API_KEY"
      },
      "models": {
        "qwen/qwen-3.7-max": {
          "name": "Qwen 3.7 Max"
        }
      }
    }
  }
}

2. 避免 Qwen3.7-Max 上下文重复重写与 Token 暴走的 Agent 规范模板(AGENTS.md)

# Agent Execution Guardrails for Qwen3.7-Max

## Core Execution Rules
1. Tool Invocation Mapping:
   - When reading repository context, use ONLY the exact registered tool name `grep_search` or `view_file`.
   - Do NOT delegate tool actions to external secondary LLMs unless explicitly invoked via verified MCP endpoint.

2. Context Conservation:
   - Do NOT re-read or dump unmodified configuration files on every iteration.
   - For file modifications, output precise diff chunks instead of whole-file rewrites.

3. Negative Constraints & Deletion Protection:
   - "Disable feature" MUST be interpreted as disabling logic (e.g., commenting out, flipping boolean flags, or setting feature toggle to false).
   - NEVER execute `rm`, `unlink`, or delete files/routes unless the prompt explicitly contains the word "DELETE" or "REMOVE".
   - If unsure between disabling vs deleting, STOP and ask the user for confirmation.

测试/工作流步骤

  1. 在 opencode.json 中配置 provider 为带有 @ai-sdk/alibaba 适配的 OpenRouter 别名,确保请求透传缓存命中标头。

  2. 检查 AGENTS.md / CLAUDE.md 中的所有指令:确保每个规则引用的工具名称与模型实际可调用的工具清单逐字一致(Verbatim matching)。

  3. 启动小范围测试:执行 3 次代码检索与修改交互,通过代理日志监控每轮输入 Token 是否呈恒定增长(未缓存)或仅增加增量(已命中缓存)。

  4. 在多轮对话中监控首 Token 延迟(TTFT)与输出 Token 速率,若发现模型反复重新解释规范或循环调用工具,立即触发 Early Stop。

原始证据与数据

  • 社区用户 Unable_Strategy 实测记录:在 OpenCode CLI 中直接使用标准 OpenRouter 配置调用 Qwen3.7-Max,8 分钟内因每次交互全量重新加载项目上下文且未命中缓存,迅速消耗 $4.00 API 额度(134 次请求产生 8,236,560 Input Tokens,40,903 Output Tokens)。

  • 经调试发现,OpenCode CLI 的缓存头注入依赖 SDK 判断,指定 npm: "@ai-sdk/alibaba" 后成功激活服务端 Prompt Caching,大幅降低重复输入开销。

  • 架构分析师 Deep_Ad1959 指出:Qwen3 系列在解析多层级自然语言 Agent 规则时,若指令中的工具描述与实际提供的 Tool Schema 不完全一致,模型会倾向于将指令降级为自由重写,进而引发长上下文循环。

适用边界

  • 本配置依赖 OpenRouter 与 Alibaba 兼容端点的 Prompt Caching 实现,第三方私有中转站若不支持缓存头透传则无法生效。

  • 规则约束可以降低误操作概率,但对极端复杂的负向指令(如带有双重否定的配置变更),仍需结合沙箱与人机确认机制。

来源摘录或观察(仅做合规短引)

社区核心讨论指出:“8.2M input on 3 prompts is the agent.md getting re-read with most of the repo on every turn... grep your agent.md for every directive that depends on a tool name, and check if that tool name appears verbatim”。

Tabbit 小编提醒

提示词内容来自公开资料与 Tabbit 编辑整理。引用前请查看原文授权与适用范围。

Qwen3.7 Max

在 Tabbit 中使用

Qwen3.7 Max

相关提示词

媒体Qwen 官方博客2026-05-20

Qwen3.7-Max 长程 Agent、前端原型与办公提示词

媒体Alibaba Cloud Model Studio2026-08-18

Qwen3.7-Max 阿里云 Model Studio 版本、价格与缓存配置

社区X.com & GitHub Community2026-08-08

Qwen3.7-Max 与多模型协同的代码阅读与审查路由配置

社区Alibaba Cloud & 通义实验室 (Tongyi Lab)2026-06-11

Qwen3.7-Max Three.js 电子魔方与 3D 物理交互原型提示词

Qwen3.7 Max

相关测评

媒体Qwen 官方博客2026-05-20

Qwen3.7-Max 官方完整基准与 35 小时自主优化实验

媒体BenchLM.ai2026-05-16

Qwen3.7-Max BenchLM 公开证据覆盖与速度账本

媒体Ofox AI2026-06-02

Qwen3.7-Max 与 Qwen3.7-Plus 三项真实任务成本与质量对照

媒体Artificial Analysis2026-05-20

Qwen3.7-Max Artificial Analysis 综合智能指数与成本速度实测