Build long-horizon agents with Grok 4.7 on Amazon Bedrock
https://aws.amazon.com/blogs/machine-learning/build-long-horizon-agents-with-grok-4-7-on-amazon-bedrock/📌 【AWS 實測】Grok 4.7 的 reasoning effort 怎麼調,72 次 agent 實驗給答案
TL;DR:AWS 用 72 次受控 agent 實驗量化 Grok 4.7 的 reasoning effort 設定對準確率與 token 成本的取捨。
多數人在用推理模型時,對 reasoning effort 的設定多半是憑直覺調一個「感覺夠用」的等級。AWS 這篇文章反其道而行,直接設計了三個「必須搜尋而非查表」的任務,把 xAI Grok 4.7 在 Amazon Bedrock 上四個 reasoning effort 等級(low、medium、high、xhigh)跑了整整 72 次,量化出一條清楚的成本/準確率曲線。
🤔 核心問題:effort 調高,agent 真的答得更準嗎?
根據 SpaceXAI(xAI)的說法,Grok 4.7 使用比 Grok 4.6 更大的基礎模型,並以更長的強化學習訓練在偏重「需要花上數小時完成」的更難任務組合上練成,號稱更擅長自我驗證與管理更長 context。SpaceXAI 公開的 benchmark 顯示,相對 Grok 4.6 進步最大的項目集中在「衡量持續性工作」而非單輪問答的類別。但 benchmark 衡量的是標準任務,AWS 想驗證的是:在真正會呼叫工具、需要多步驟驗證的 agent 場景裡,reasoning effort 的邊際效益長什麼樣子。
🧩 三個「只能靠搜尋,不能查表」的任務
AWS 建了一個包含 20 個服務、7 個工具的合成環境,設計三個任務:從兩個服務的告警中診斷故障、在互相牽制的限制條件下安排維護排程,以及在預算限制下選出最佳的一組遷移方案。每個任務都刻意設計成「答案無法直接從資料讀出,必須先提出候選答案再驗證」,且透過窮舉方式驗證每個任務都恰好只有一個正確答案。
為了讓評測結果可信,AWS 遵循幾個原則:在提示詞中寫清楚評分依賴的每一條規則(例如明確說明「故障的服務不會自己發出告警」),用窮舉法先證明每個任務只有一個答案,只評分要求的最終結論行(例如 FINAL: auth, checkout)而不是整段推理過程,並把「格式缺失」與「答案錯誤」分開追蹤。系統提示詞特別要求 agent 在給出答案前自我檢查。整個 agent loop 是標準的工具呼叫迴圈:帶著設定好的 reasoning_effort 呼叫模型、執行回傳的工具呼叫、把結果掛回對應的 tool_call_id,重複直到模型不再請求工具,並全程追蹤 prompt_tokens 與 completion_tokens。
📊 xhigh 全對,low 用八分之一 token 答對 15/18
三個任務在四個 effort 等級下各跑 6 次,共 72 次,整體答對 67 次。
| Effort | 正確率 | 平均輸出 token | 中位秒數 |
|---|---|---|---|
| xhigh | 18/18 | 9,147 | 較長 |
| high | 17/18 | — | — |
| medium | 17/18 | — | — |
| low | 15/18 | 1,184 | 18 秒 |
值得注意的是,工具呼叫次數在各個 effort 等級幾乎不變(每次運行 17.2 到 18.7 次),也就是說 effort 改變的不是 agent「探索了多少」,而是它「針對同樣的事實做了多少推理」。由於每個任務每個等級只跑 6 次,等級之間的差異屬於「指向性」而非統計上的結論,但三個任務呈現的方向一致。
💡 low 的成本/準確率比值其實很划算
在 low 等級下,agent 用大約 xhigh 八分之一的輸出 token,答對 18 題中的 15 題,中位執行時間只要 18 秒。對於可以接受稍低完成率、或答案會經過人工複核的場景,low 是效率相當高的選擇。
⚠️ 樣本量小,結論僅供參考方向
每個任務每個 effort 等級只跑 6 次,AWS 自己也坦承這樣的差異只能說是「指向性」而非統計上的確定結論。另外,reasoning token 會被計入輸出 token 並從 max_completion_tokens 扣除,如果上限設太低、推理階段就把額度用完,回應會沒有答案文字,AWS 建議在 agent 程式碼中特別檢查這種空內容的情況。
🎯 實務上怎麼用
如果你要在 Bedrock 上串接 Grok 4.7 做 agent,關鍵行動是針對自己的任務形狀重做這套測量,而不是直接套用別人的 benchmark 結論;同時在 Converse API 中,把 reasoning effort 等參數放進 additionalModelRequestFields,並把 maxTokens 設得足夠寬裕,讓推理和最終答案都有空間完成。
🔗 來源
- 標題:Build long-horizon agents with Grok 4.7 on Amazon Bedrock
- 作者/機構:Suheel Farooq(AWS Machine Learning Blog)
- 連結:https://aws.amazon.com/blogs/machine-learning/build-long-horizon-agents-with-grok-4-7-on-amazon-bedrock/
#Grok47 #AmazonBedrock #AgenticAI #ReasoningEffort #LLMEvaluation #ToolCalling #xAI #AIAgents #PromptEngineering #AWS
原始資料 AWS ML · 收集於 2026-10-13
摘要原文
SpaceXAI’s Grok 4.7 is now available on Amazon Bedrock, which offers a choice of foundation models (FMs) from multiple providers. According to SpaceXAI, Grok 4.7 is trained to work longer on more difficult tasks and knows when to check its own work. That matters most for agents, which carry a task through many steps and must verify what they find along the way. An agent that works this way has to do more than look things up. It has to form a candidate answer, check it against what it has learned, and refine it until it fits. Grok 4.7 exposes a reasoning effort setting that controls how much deliberation happens before each response, and for agent workloads a practical question is which level to run. In this post, we build a tool-calling agent on Grok 4.7 and evaluate it on three tasks that require search rather than lookup. The tasks are diagnosing a two-service outage from its alerts, scheduling maintenance under interacting constraints, and choosing an optimal set of migrations under a budget. Each task has exactly one correct answer, verified by brute force. We ran all three at every reasoning effort level, six times each, for 72 agent runs. The agent answered 67 of the 72 runs correctly. At xhigh it answered all 18 correctly, and at low it answered 15 of 18 while using about an eighth of the output tokens. That gives a clear trade-off you can tune per request, and we show how to measure it on your own tasks and how to monitor it in production. We report token counts rather than currency throughout. Token prices change, and the counts are what your own costs are derived from, so a measurement expressed in tokens stays valid. According to SpaceXAI, Grok 4.7 uses a larger base model than Grok 4.6 and was trained with a longer reinforcement learning run on a harder mix of tasks. This mix is weighted toward problems that take many hours to complete. SpaceXAI reports that the model is better at verifying its own work and at managing longer context. SpaceXAI’s published benchmark results follow that emphasis. The largest reported gains over Grok 4.6 appear in the categories that measure sustained work rather than single-turn answers. Source: SpaceXAI, Introducing Grok 4.7 ( https://x.ai/news/grok-4-7 ). Scores are as published by SpaceXAI at the time of the model launch. Benchmarks show how a model performs across standard tasks. For your own workload, the useful next step is to measure on tasks shaped like yours, which is what the rest of this post walks through. SpaceXAI lists a 500K token context window for Grok 4.7, with text and image input and text output. On Amazon Bedrock, the model supports configurable reasoning effort, tool calling, and structured output. Grok 4.7 runs on the bedrock-runtime endpoint and is accessed through a cross-Region inference profile. Two profiles are available: Cross-Region inference routes requests across multiple AWS Regions, which gives you higher throughput without managing capacity Region by Region. Requests name one of the inference profiles rather than a bare model ID. The model supports the OpenAI-compatible Chat Completions and Responses APIs, and the Amazon Bedrock Converse API. On Converse, reasoning is returned as a reasoningContent block alongside the text block. In inferenceConfig , set maxTokens only, and put model-specific parameters, such as reasoning effort, in additionalModelRequestFields . For the current list of supported Regions, service tiers, and token prices, see the Grok 4.7 model card in the Amazon Bedrock User Guide and the Amazon Bedrock pricing page ( https://aws.amazon.com/bedrock/pricing/ ). Your AWS Identity and Access Management (IAM) identity needs bedrock:InvokeModel on both the inference profile and your account’s default project: Include both resources in the policy statement. The default project permission is required in addition to the inference profile. For production use, we recommend generating a short-term bearer token from your existing AWS credentials, so authentication stays tied to your IAM identity and no long-lived secret is stored: Reasoning tokens count as output tokens and draw down max_completion_tokens before the answer text is produced, so size the limit to leave room for both. If the limit is reached during reasoning, the response returns without answer text, so check for empty content in agent code and raise the limit if you see it. Our runs used a limit of 32,768 tokens, which left headroom at every effort level. Grok 4.7 supports four effort levels: low , medium , high , and xhigh . Effort levels can change between model versions, so it is worth confirming them against the service rather than hardcoding a list: Many agent evaluations test diligence: read a record, filter it, add it up. Those tasks are worth having, but to see what reasoning effort contributes, a task has to require search: the answer can’t be read off the data, it has to be proposed and then checked. We built a synthetic environment of 20 services, exposed through seven tools, and three tasks on top of it. Every task has exactly one correct answer, and each is built so that a quick heuristic is not enough to find it. Four practices keep a measurement like this trustworthy, and they apply to most agent evaluations. State every rule the grader relies on. If the prompt leaves an edge case open, a reasonable answer can be scored as wrong, and the evaluation ends up measuring the specification rather than the model. The diagnosis prompt, for example, says explicitly that a failed service raises no alert of its own. Prove each task has one answer. Each environment is small enough to enumerate, so we checked every candidate answer before running anything. For the schedule, that is a few lines: Grade a required final line, not the whole response. Each prompt asks the agent to end with a line such as FINAL: auth, checkout . The grader reads only that line, so a response that discusses other candidates while explaining its reasoning is graded on its conclusion: Track format separately from correctness. A missing final line is a different signal from an incorrect one. In our runs, all 72 responses included a gradeable final line. Constrain tool parameters with an enum where the valid values are known, so every tool call targets a real resource: The system prompt is deliberately short, and asks the agent to check its answer before giving it: The agent loop is a standard tool-calling loop: call the model with reasoning_effort set, execute each returned tool call, append the result keyed by tool_call_id , and repeat until the model stops requesting tools. Tracking prompt_tokens and completion_tokens across the loop gives the token counts reported in the following section. Six runs of each task at each effort level, 72 runs in total. The agent answered 67 correctly. Figure 1: Share of runs answered correctly at each reasoning effort level (left), and mean output tokens per run with median seconds per run overlaid (right) xhigh answered every run correctly. All 18 runs across the three tasks were correct at xhigh , and medium and high answered 17 of 18 each. With six runs per task and level, the differences between levels are indicative rather than statistically conclusive, and the direction was consistent across all three tasks. Effort changes how much the agent reasons, not how much it explores. Tool calls were essentially flat, between 17.2 and 18.7 per run at every level. The agent gathered the same facts regardless of effort, and what changed was how much reasoning it applied to them, with output tokens rising from 1,184 at low to 9,147 at xhigh . low offers a strong cost-to-quality ratio. At low , the agent answered 15 of 18 runs correctly using about an eighth of the output tokens of xhigh , with a median run of 18 seconds. Where a slightly lower completion rate is acceptable, or where answers are reviewed downstream, low is an efficient choice.
由 claude-code/sonnet 自動生成