mirror of
https://github.com/andrewyng/openworker.git
synced 2026-09-09 20:15:59 +00:00
Imported from andrewyng/aisuite@1b4bbf303e (contents of its platform/ directory, hoisted to the repo root). Development history prior to this commit lives in that repository. Co-authored-by: Devika <devikaverma11@gmail.com>
44 lines
1.8 KiB
Python
44 lines
1.8 KiB
Python
"""The `propose_plan` tool — the agent presents its plan and asks to start executing.
|
|
|
|
Registered only when the session starts in plan mode. Like `request_directory`, it is
|
|
intercepted by the TurnEngine: it emits a PLAN_PROPOSED event and waits for the user's
|
|
out-of-band decision. Approval flips the live PermissionEngine out of plan mode (same
|
|
session, full exploration context kept); rejection returns the user's feedback so the
|
|
agent can revise the plan. The callable here is only a schema carrier + a safe fallback
|
|
for surfaces without an approver.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from aisuite.agents import ToolMetadata, tool
|
|
|
|
|
|
def propose_plan_tool() -> object:
|
|
def propose_plan(plan: str) -> dict:
|
|
"""Present your implementation plan to the user for approval. Use this once you
|
|
have explored enough to commit to an approach: summarize what you'll change, in
|
|
which files, and how you'll verify it. If approved, the session switches out of
|
|
read-only plan mode and you implement the plan; if rejected, revise it using the
|
|
feedback in the result. Don't start describing implementation steps as if you
|
|
were doing them — propose first.
|
|
"""
|
|
# Real handling lives in the engine (it needs the out-of-band approval round-trip).
|
|
# This body only runs if no approver is wired (e.g. a headless surface).
|
|
return {
|
|
"approved": False,
|
|
"error": "plan approval isn't available in this surface",
|
|
}
|
|
|
|
return tool(
|
|
propose_plan,
|
|
metadata=ToolMetadata(
|
|
category="planning",
|
|
risk_level="low",
|
|
capabilities=["plan"],
|
|
description=(
|
|
"Present the implementation plan for user approval; approval exits "
|
|
"read-only plan mode and starts execution."
|
|
),
|
|
),
|
|
)
|