agora.fleet.auto_hooks

Automatic validation + git + completion hooks fired after tool calls.

Weak LLMs (qwen2.5:7b and similar) cannot reliably juggle a multi-step protocol of write_file → check_python → run_python_import → git_commit → mark_complete. They burn iterations on orchestration and bail before calling mark_complete. This module runs those validation + bookkeeping tools automatically on the framework side, so the agent only has to decide what to write.

The hooks are passive from the LLM’s perspective: the results of auto-run tools are appended to the message history as synthetic tool_result entries, so the model sees check_python errors on its next turn and can fix the file — but it never has to remember to call the tool itself.

Functions

run_auto_hooks(call_name, call_arguments, ...)

Return the list of auto-invocations triggered by a finished tool call.

synthesize_mark_complete(ctx, final_text)

Append a synthetic mark_complete entry if the LLM never called one.

Classes

AutoHookResult

One automatically-run tool's output.

class agora.fleet.auto_hooks.AutoHookResult[source]

Bases: object

One automatically-run tool’s output.

tool_name: str
arguments: dict[str, Any]
result: str
success: bool
__init__(tool_name, arguments, result, success)
async agora.fleet.auto_hooks.run_auto_hooks(call_name, call_arguments, call_result, ctx)[source]

Return the list of auto-invocations triggered by a finished tool call.

Currently only write_file triggers hooks. The chain is:

  • on .py files: check_python → (if clean) run_python_import

  • on requirements.txt: check_requirements

  • after any successful write with a git repo: git_commit

A hook chain stops on the first failure so the agent sees one focused error at a time.

agora.fleet.auto_hooks.synthesize_mark_complete(ctx, final_text)[source]

Append a synthetic mark_complete entry if the LLM never called one.

Returns True when a synthetic entry was appended, False when the LLM’s own mark_complete was present (nothing to do).

The summary is derived from final_text (last LLM content) and the artifact list is taken from ctx.written_files. This keeps the _postcond_mark_complete contract satisfied even when the model bails at tool_calls=0 without the courtesy of calling the tool itself — which is the dominant failure mode on weak models.