最新资讯
stackoverflow.blog 欢迎来到芯片时代:半导体制造、AI 数据中心与芯片设计的未来 pub.towardsai.net Netflix 科学家建议重采样 LLM 评判:5 次仅将误差棒缩小 13% pub.towardsai.net Jev 作为 LLM 前的静默层:构建提示感知的模型路由器 reddit.com OpenAI 称 Astra 仅满足 10% 安全任务标准 dev.to FreeToken:在自有 GPU 上运行前沿 MoE 模型及其内存需求 dev.to 当 AI Agent 说“完成”时,究竟完成了什么? dev.to 部署 Underdog Bark 3.0 Pro:逐字转写、自定义后端与分块设置 dev.to 为艰难对话构建 AI:五个 Agent、一条安全正则与一位盲评监督者 techcrunch.com Palo Alto Networks 洽谈以 5 亿美元收购 AI Agent 安全初创公司 Clutch theinformation.com 黄仁勋被要求就涉华间谍指控向国会作简报 www.infoq.com Edera 推出 Object Capability Bounded Authority,试图将凭证与 AI Agent 工作负载隔离 wechat 这波杀疯了!旗舰级模型不限量、1个月视频额度免费领
多元动态
登录 注册
智能体 dev.to · @ElementalSilk

什么是 AI Agent Harness?

原文 我的收藏

文章解释 AI Agent Harness 是围绕 LLM 的软件环境,为模型提供工具、上下文、记忆与执行环境,使其能完成多步任务。核心是 reason-act-observe 循环:模型推理决定动作,工具执行,模型评估结果并继续循环,直至任务完成。作者用 Model(Reason)+Harness(Action)=Agent 概括模型与执行环境的分工。

AI推荐理由 对 AI Agent Harness 的概念性科普,明确给出 Model(Reason)+Harness(Action)=Agent 的框架和 reason-act-observe 循环,对理解 Agent 架构有参考价值;但属入门解释,无新事实或可验证数据,信息密度一般。

62

正文

An AI agent harness is the software environment that surrounds an LLM to give it the tools and context needed to complete multi-step tasks. It turns your basic LLM calls to an operational system executing real world task. The model reasons through a prompt and decides the actions. The harness connects the agent it to the tools, systems, memory and execution environments needed to carry out those actions. In a AI harness Agents typically run in a loop: an LLM decides what to do, a tool executes, a model evaluates the results and then continues in that loop until the task is complete. Model(Reason)+ Harness(Action)= Agent (Output) Or Model (Brain) Agent (as the Body) and Harness as the hands/tools the body uses to finish a given task. You get the picture. The reason - act - observe loop This is at the core of many AI agents. Understanding this loop is critical to understanding how a harness works. Reason- The model reads everything in its context, including the task, relevant memory and previous results, then decides what action to take next. Act - The harness carries out that action by running a tool, executing code in a sandbox, calling an API or writing to storage. Observe- The harness captures the result and feeds it back to the model as new context. Repeat - The model uses that result to decide what to do next. The loop continues until the task is complete. The ReAct: Synergizing Reasoning and Acting in Language Models- is published in this paper and is an excellent read. Ok enough of "simile", let's jump to a concrete example Let's say we have a file in our local system "sales and vendor commission.txt" and we want to perform complex and kind of weird calculation on this. This is your final prompt - "I have a text file called 'sales and commission.txt' in the current directory - if it exists, extract the column with header 'Sales Person Name' , calculate it's word count. Also, if the word count is > 20 calculate the vendor commission which is 15% of column header Sales or if the word count is dict[str, Any]: try: tree = ast.parse(expression, mode="eval") result = _safe_eval(tree.body) return {"result": result} except Exception as e: return {"error": f"Could not evaluate expression: {e}"} def tool_get_current_time(utc_offset_hours: float = 0) -> dict[str, Any]: now = datetime.now(timezone.utc) if utc_offset_hours: from datetime import timedelta now = now + timedelta(hours=utc_offset_hours) return {"iso_timestamp": now.isoformat(), "utc_offset_hours": utc_offset_hours} def tool_word_count(text: str) -> dict[str, Any]: words = text.split() return {"word_count": len(words), "character_count": len(text)} Enter fullscreen mode Exit fullscreen mode Step 3 - System Prompt self.system_prompt = system_prompt or ( "You are a helpful assistant with access to tools. " "Use tools whenever they would give a more accurate or reliable answer " "than reasoning alone (e.g. always use the calculator for arithmetic). " "Once you have everything you need, give a clear, direct final answer." ) Enter fullscreen mode Exit fullscreen mode Step 4 - This is the heart of the whole logic, Use the stop_reason to check if the Agent is done is the reason is tool_use then keep going in a loop if response.stop_reason != "tool_use": # Final answer reached. final_text = "".join( block.text for block in response.content if block.type == "text" ) return final_text # Otherwise, execute every requested tool call and collect results. tool_results = [] for block in response.content: if block.type != "tool_use": continue self._log(f"[tool call] {block.name}({json.dumps(block.input)})") result_json = self._execute_tool(block.name, block.input) self._log(f"[tool result] {result_json}") tool_results.append( { "type": "tool_result", "tool_use_id": block.id, "content": result_json, } ) Enter fullscreen mode Exit fullscreen mode Core loop: Send the conversation + tool schemas to Claude. If stop_reason == "tool_use", execute each requested tool locally and append the results as tool_result blocks. Loop back to step 1. Stop when Claude returns a final text answer (stop_reason == "end_turn") or max_iterations is hit (safety limit).

来源报道 · 1 篇 · 以下链接均前往原始媒体

ElementalSilk 什么是 AI Agent Harness? 09-24 · 原文发布
← 返回精选动态 原文

更多内容