agora.fleet.inner_tools

Inner tool definitions and executors per agent role.

Tools are described to the LLM as JSON-schema-ish dicts. At execution time the runtime resolves a tool call’s name to a coroutine via get_tool_executor() and feeds back the result.

Tool categories: - research: web_search, fetch_url (optional — require injected callables) - filesystem: read_file, write_file, list_directory (scoped to work_dir) - git: git_commit, git_diff, git_log (Sprint 4 wires in a real RepoManager) - coordination: report_progress, request_review, mark_complete, report_learning

Module Attributes

AUTO_HOOKED_TOOL_NAMES

Tool names hidden from the LLM when ToolContext.auto_hooks_enabled is True.

Functions

get_tool_definitions(role, *[, ...])

Return the tool schemas for the given role.

get_tool_executor(role, context)

Return a name -> async callable mapping for the role's tools.

Classes

ToolContext

Per-task execution context threaded through every inner tool call.

class agora.fleet.inner_tools.ToolContext[source]

Bases: object

Per-task execution context threaded through every inner tool call.

The ToolContext holds the work directory, the Matrix client, the git repo manager, and per-task mutable state (written_files, progress_log, completions, reported_learnings, the plan_draft for plan-authoring stages). It’s the single object every tool factory receives, so adding a new piece of per-task state is a one-line change here.

Several flags gate what tools are exposed to the model:

  • auto_hooks_enabled — when True, the framework runs validation + git_commit + mark_complete automatically after write_file, and those tools are hidden from the LLM manifest.

  • plan_authoring_enabled — gates the plan_* tool category; only the plan-builder runner enables this.

  • write_file_blocked — flipped by the overwrite guard once the model tries to clobber a file outside its declared output path. Stays set for the rest of the task so write_file is dropped from the manifest, forcing the model onto the edit primitives.

Most fields default to safe no-op values; tests construct ToolContext instances with fakes for matrix_client and git_repo to exercise tools in isolation.

work_dir: str
matrix_client: MatrixClientProtocol
agent_room_id: str
project_room_id: str
matrix_live: bool = True

no room, no human. Tools MUST branch on this rather than posting into the void — informational tools say “recorded to log” instead of claiming delivery, and tools that block on a person refuse loudly rather than pretend. Defaults True so every existing caller/test keeps today’s behaviour.

Type:

False when the Matrix surface is off (NullMatrixClient)

git_repo: Any = None
search_fn: Callable[[str], Awaitable[str]] | None = None
fetch_fn: Callable[[str], Awaitable[str]] | None = None
knowledge_refs: list[str]
knowledge_fetcher: Callable[[str], Awaitable[str]] | None = None
control: Any = None
progress_log: list[dict[str, Any]]
reviews_requested: list[dict[str, Any]]
completions: list[dict[str, Any]]
reported_learnings: list[dict[str, Any]]
written_files: list[str]
write_file_blocked: bool = False
auto_hooks_enabled: bool = False
expected_output_path: str = ''
task_focus: str = ''
distill_fn: Callable[[str, str], Awaitable[str]] | None = None
read_distill_threshold: int = 8000
plan_draft: Any = None
plan_authoring_enabled: bool = False
active_test_file: str = ''
tool_errors: str = 'raw'
nudge_budget: int = 0
review_budget: int = 0
salvage_budget: int = 0
run_check_records: list[dict[str, Any]]
__init__(work_dir, matrix_client, agent_room_id, project_room_id, matrix_live=True, git_repo=None, search_fn=None, fetch_fn=None, knowledge_refs=<factory>, knowledge_fetcher=None, control=None, progress_log=<factory>, reviews_requested=<factory>, completions=<factory>, reported_learnings=<factory>, written_files=<factory>, write_file_blocked=False, auto_hooks_enabled=False, expected_output_path='', task_focus='', distill_fn=None, read_distill_threshold=8000, plan_draft=None, plan_authoring_enabled=False, active_test_file='', tool_errors='raw', nudge_budget=0, review_budget=0, salvage_budget=0, run_check_records=<factory>)
agora.fleet.inner_tools.AUTO_HOOKED_TOOL_NAMES: frozenset[str] = frozenset({'check_python', 'git_commit', 'git_diff', 'git_log', 'report_learning'})

Tool names hidden from the LLM when ToolContext.auto_hooks_enabled is True. The framework runs these automatically after write_file, so exposing them to weak models only adds cognitive overhead.

agora.fleet.inner_tools.get_tool_definitions(role, *, auto_hooks_enabled=False, plan_authoring_enabled=False, fill_test_body_bound=False)[source]

Return the tool schemas for the given role.

Always hides the deprecated granular plan-authoring tools. When auto_hooks_enabled is set, additionally hides tools whose behaviour is already automated by agora.fleet.auto_hooks.

When plan_authoring_enabled is False (default), drops the entire plan_authoring category — the plan-builder runner opts in via ToolContext; other runners don’t, so emitted plans whose architect role would otherwise see plan_upsert_agent / plan_add_task_spec don’t accidentally drift into meta-authoring calls. Also hides await_user_decision in the build path: the plan-builder legitimately drives user decisions via declarative decision STAGES (framework-owned); build agents calling await_user_decision ad-hoc blocks on 300s timeouts without advancing the task — observed disruption in live url-shortener build runs.

v2.7: fill_test_body_bound gates the fill_test_body tool. It only makes sense inside a fill_assertions stage where the stage runner has bound ctx.active_test_file; everywhere else the tool is hidden so the model can’t pick it up as a generic file-editor.

agora.fleet.inner_tools.get_tool_executor(role, context)[source]

Return a name -> async callable mapping for the role’s tools.

Each callable accepts the LLM-provided arguments dict and returns a string result that is fed back to the model.