Skip to content

Improve agent prompt determinism - #8

Open
snipextt wants to merge 6 commits into
mainfrom
improve/agent-engine-prompt-determinism
Open

Improve agent prompt determinism#8
snipextt wants to merge 6 commits into
mainfrom
improve/agent-engine-prompt-determinism

Conversation

@snipextt

@snipextt snipextt commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Tighten Wacht coordinator, executor, reviewer, conversation, memory, workspace, and live-context prompt contracts.
  • Replace stale task workspace guidance with the current JOURNAL.md, artifacts/, audit/, and review/ paths.
  • Clarify tool-schema authority, lifecycle ownership, completion, abort, verification, and runtime-signal handling.
  • Add an LlmRequestFailed runtime signal so retries receive corrective guidance after a failed model request.

Validation

  • cargo check --workspace --locked
  • git diff --check

No tests were added or run per scope. No deployment or service restart was included.

Summary by CodeRabbit

  • Bug Fixes

    • Improved handling of AI request failures with clearer runtime warnings.
    • Improved detection and reporting of unknown tools, repeated tool-call cycles, and persistent failures.
    • Preserved blocked, cancelled, and completed outcomes accurately during task handoffs.
  • Improvements

    • Strengthened task execution with clearer progress tracking, completion requirements, blocker handling, and deliverable reporting.
    • Expanded project, memory, file, web, and workspace capabilities.
    • Enhanced safety guidance, review workflows, verification practices, and task-history handling.
    • Improved completion guidance for text-only conversations and coordinator-managed assignments.

@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@snipextt, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 40 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 651b0626-20f5-4cdf-b19a-c4381a9dc9eb

📥 Commits

Reviewing files that changed from the base of the PR and between 0de0f48 and cb8ef65.

📒 Files selected for processing (3)
  • agent-engine/src/filesystem/text_io.rs
  • templatekit/src/prompts/delegated_execution_system.md
  • templatekit/src/prompts/service_execution_system.md
📝 Walkthrough

Walkthrough

The change adds runtime signals for LLM failures, unknown tools, tool failures, and tool-call cycles. It revises agent contracts for live tools, memory, journaling, lifecycle ownership, termination, conversation behavior, and input safety.

Changes

Runtime and agent operating contracts

Layer / File(s) Summary
Runtime signals and tool-call cycle detection
agent-engine/src/executor/core.rs, agent-engine/src/executor/agent_loop/mod.rs
The executor emits structured warning signals for LLM failures, unknown tools, sustained tool failures, and recurring tool-call signatures. It retains adjacent-repeat detection and adds a bounded six-signature history.
Blocked completion and handoff persistence
agent-engine/src/executor/agent_loop/meta_tools/..., agent-engine/src/executor/agent_loop/mod.rs, agent-engine/src/executor/agent_loop/prompt.rs, agent-engine/src/executor/agent_loop/tool_schema.rs, agent-engine/src/executor/project/task_commands.rs, agent-engine/src/executor/tools/definitions/tool_definitions_project.rs, templatekit/src/templates/worker_assignment_execution_context.hbs
Completion handoffs detect blockers and persist blocked outcomes. Termination guidance separates clean blocked handoffs from aborting failed loops. Task-tool availability and coordinator status values are updated.
Workspace and journal completion contract
templatekit/src/templates/task_workspace_brief.hbs, templatekit/src/prompts/{delegated_execution_system.md,service_execution_system.md}, templatekit/src/prompts/sandbox_environment.md, templatekit/src/templates/worker_assignment_execution_context.hbs
Execution requires task instructions, journal updates, durable artifact paths, read-only audit handling, and concrete blockers and next actions before termination.
Tool, role, memory, and conversation contracts
templatekit/src/prompts/{coordinator_system.md,delegated_execution_system.md,memory_discipline.md,reviewer_system.md,service_execution_system.md,shared_operating_style.md,conversation_agent_system.md}, templatekit/src/templates/agent_loop_live_context.hbs
Prompts define live tool schemas, memory operations, verification, progress, user questions, role-specific lifecycle rules, subject-based communication, runtime-signal handling, and text-only conversation completion.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant AgentLoop
  participant AgentExecutor
  participant RuntimeSignal
  AgentLoop->>AgentExecutor: process model response and tool calls
  AgentExecutor->>RuntimeSignal: emit failure, unknown-tool, escalation, or cycle signal
  AgentExecutor-->>AgentLoop: continue execution or return the original LLM error
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the pull request's main goal of improving determinism across agent prompts and runtime guidance.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch improve/agent-engine-prompt-determinism

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
templatekit/src/prompts/delegated_execution_system.md (1)

152-157: 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

Align executor termination rules with the runtime outcome contract.

terminate_loop accepts blockers/next_actions but does not update assignment_result_status as a non-completed terminal handoff, while abort_task(blocked) is the only runtime path that records blocked assignment/result status. Reconcile the shared/delegated/service prompts so clean blocked termination actually persists the blocked state with a result summary, and keep abort_task(blocked) only for impossible/unrouteable cases.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@templatekit/src/prompts/delegated_execution_system.md` around lines 152 -
157, Update the terminal rules in
templatekit/src/prompts/delegated_execution_system.md (lines 152-157) and
templatekit/src/prompts/service_execution_system.md (lines 170-178) so clean
blocked termination uses terminate_loop with blockers/next_actions and records a
blocked assignment/result status plus a concise result summary; reserve
abort_task(blocked) for impossible or unrouteable cases where the loop cannot
exit cleanly. Align both prompt definitions with the runtime outcome contract
and preserve the single terminate_loop terminal shape.
🧹 Nitpick comments (1)
agent-engine/src/executor/core.rs (1)

35-35: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add focused tests for the new RuntimeSignal contract.

The change affects enum construction, key(), message(), is_warning(), and render(). Add assertions for the llm_request_failed key, recovery message, warning classification, and rendered output. cargo check does not validate these runtime behaviors.

Also applies to: 55-55, 82-82, 94-94

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@agent-engine/src/executor/core.rs` at line 35, Add focused tests for the
RuntimeSignal enum covering the LlmRequestFailed variant and its key(),
message(), is_warning(), and render() behavior. Assert the expected
llm_request_failed key, recovery message, warning classification, and rendered
output, including the other changed variants identified in the diff where
applicable.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@templatekit/src/prompts/conversation_agent_system.md`:
- Around line 85-87: Update update_scope_for_conversation so lifecycle fields
remain coordinator-owned without exception: remove permission for the
conversation agent to send status, schedule, result_summary, artifacts,
findings, cautions, or next even when explicitly requested. Align the
corresponding guidance around the coordinator-owned fields so all policy-field
changes are routed through the coordinator.
- Line 192: Update the first-turn guidance around [first_turn].must_include and
no_status_narration so their requirements do not conflict: permit the first
tool-call companion text only when it is a clarifying question or non-progress
acknowledgement, or explicitly define a narrowly scoped first-turn exception.
Remove progress-style narration from the required examples while preserving the
prohibition on routine status updates.

In `@templatekit/src/prompts/reviewer_system.md`:
- Around line 57-61: Update the [timeline.tool_output_preservation] verification
guidance to prohibit replaying arbitrary executor tool inputs, including
mutating, destructive, credential-bearing, or network commands. Replace the
current rerun requirement with reviewer-authored, explicitly allow-listed
checks, and update the repeated rule at the referenced verification guidance to
match.

In `@templatekit/src/prompts/shared_operating_style.md`:
- Around line 230-232: Update the only_exits template rule so it applies only to
non-conversation threads, or explicitly permits the required plain-text/no-tool
completion for conversation threads. Preserve the existing terminate_loop,
ask_user, abort_task, and notify_user conditions for non-conversation runs.

In `@templatekit/src/templates/task_workspace_brief.hbs`:
- Around line 18-21: Update the task workspace instructions in
task_workspace_brief.hbs to explicitly identify /task/audit/ as a runtime-owned,
read-only tool-call log that agents must not write evidence or review files
into; direct agent-created evidence and review material to the appropriate
writable location, while preserving the existing /task/review/ guidance.

---

Outside diff comments:
In `@templatekit/src/prompts/delegated_execution_system.md`:
- Around line 152-157: Update the terminal rules in
templatekit/src/prompts/delegated_execution_system.md (lines 152-157) and
templatekit/src/prompts/service_execution_system.md (lines 170-178) so clean
blocked termination uses terminate_loop with blockers/next_actions and records a
blocked assignment/result status plus a concise result summary; reserve
abort_task(blocked) for impossible or unrouteable cases where the loop cannot
exit cleanly. Align both prompt definitions with the runtime outcome contract
and preserve the single terminate_loop terminal shape.

---

Nitpick comments:
In `@agent-engine/src/executor/core.rs`:
- Line 35: Add focused tests for the RuntimeSignal enum covering the
LlmRequestFailed variant and its key(), message(), is_warning(), and render()
behavior. Assert the expected llm_request_failed key, recovery message, warning
classification, and rendered output, including the other changed variants
identified in the diff where applicable.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 55f38ca1-c8a8-4a18-bd73-7ee6f4fc2f73

📥 Commits

Reviewing files that changed from the base of the PR and between 11c95b4 and 1eadbc4.

📒 Files selected for processing (11)
  • agent-engine/src/executor/agent_loop/mod.rs
  • agent-engine/src/executor/core.rs
  • templatekit/src/prompts/conversation_agent_system.md
  • templatekit/src/prompts/coordinator_system.md
  • templatekit/src/prompts/delegated_execution_system.md
  • templatekit/src/prompts/memory_discipline.md
  • templatekit/src/prompts/reviewer_system.md
  • templatekit/src/prompts/service_execution_system.md
  • templatekit/src/prompts/shared_operating_style.md
  • templatekit/src/templates/agent_loop_live_context.hbs
  • templatekit/src/templates/task_workspace_brief.hbs

Comment thread templatekit/src/prompts/conversation_agent_system.md Outdated
Comment thread templatekit/src/prompts/conversation_agent_system.md
Comment thread templatekit/src/prompts/reviewer_system.md Outdated
Comment thread templatekit/src/prompts/shared_operating_style.md Outdated
Comment thread templatekit/src/templates/task_workspace_brief.hbs Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@agent-engine/src/executor/agent_loop/mod.rs`:
- Around line 1459-1486: Update the non-adjacent cycle detection loop in the
recent_tool_call_signatures scan to iterate earlier entries from newest to
oldest, excluding the current entry. Preserve the existing cycle_len calculation
and signal behavior so the first match reports the nearest recurrence and
tightest cycle period.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 28d1a5bb-73c0-497e-9436-5986cc87eebf

📥 Commits

Reviewing files that changed from the base of the PR and between 1eadbc4 and fda714c.

📒 Files selected for processing (6)
  • agent-engine/src/executor/agent_loop/mod.rs
  • agent-engine/src/executor/core.rs
  • templatekit/src/prompts/coordinator_system.md
  • templatekit/src/prompts/delegated_execution_system.md
  • templatekit/src/prompts/service_execution_system.md
  • templatekit/src/prompts/shared_operating_style.md
🚧 Files skipped from review as they are similar to previous changes (3)
  • templatekit/src/prompts/delegated_execution_system.md
  • templatekit/src/prompts/coordinator_system.md
  • templatekit/src/prompts/service_execution_system.md

Comment thread agent-engine/src/executor/agent_loop/mod.rs

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@agent-engine/src/executor/agent_loop/meta_tools/mod.rs`:
- Around line 215-216: Update the `abort_tool` instructions to make
`terminate_loop` with concrete `blockers` and a handoff in `next_actions` the
routine exit for blocked work, removing the conflicting requirement to call
`update_project_task` with status `blocked`; retain `abort_task` only for loops
that cannot exit cleanly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 7a0255d9-41a4-492d-bf5c-4e3772faaff7

📥 Commits

Reviewing files that changed from the base of the PR and between fda714c and e6fa23f.

📒 Files selected for processing (10)
  • agent-engine/src/executor/agent_loop/meta_tools/complete.rs
  • agent-engine/src/executor/agent_loop/meta_tools/mod.rs
  • agent-engine/src/executor/agent_loop/mod.rs
  • templatekit/src/prompts/conversation_agent_system.md
  • templatekit/src/prompts/delegated_execution_system.md
  • templatekit/src/prompts/reviewer_system.md
  • templatekit/src/prompts/service_execution_system.md
  • templatekit/src/prompts/shared_operating_style.md
  • templatekit/src/templates/task_workspace_brief.hbs
  • templatekit/src/templates/worker_assignment_execution_context.hbs
🚧 Files skipped from review as they are similar to previous changes (6)
  • templatekit/src/templates/task_workspace_brief.hbs
  • templatekit/src/prompts/service_execution_system.md
  • templatekit/src/prompts/delegated_execution_system.md
  • templatekit/src/prompts/conversation_agent_system.md
  • templatekit/src/prompts/reviewer_system.md
  • templatekit/src/prompts/shared_operating_style.md

Comment thread agent-engine/src/executor/agent_loop/meta_tools/mod.rs Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 7

🧹 Nitpick comments (1)
templatekit/src/prompts/reviewer_system.md (1)

133-137: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Narrow the shell-discovery prohibition.

The tools.external rule says "any shell discovery", but this prompt also requires execute_command with ls and grep for audit inspection. State that the prohibition applies to external-tool discovery, not required audit or repository inspection.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@templatekit/src/prompts/reviewer_system.md` around lines 133 - 137, Update
the tools.external configuration near search_tools so the shell-discovery
prohibition is limited to discovering external tools, while explicitly allowing
required audit and repository inspection commands such as execute_command with
ls and grep.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@agent-engine/src/executor/agent_loop/meta_tools/mod.rs`:
- Around line 210-215: Update the terminate_loop description to make
feedback-resolution responsibility coordinator-specific: require
coordinator-owned feedback to be resolved when applicable, without instructing
execution or reviewer roles to resolve feedback they do not own. Preserve the
existing self-review guidance for actions, journaling, blockers, and handoff.

In `@agent-engine/src/executor/tools/definitions/tool_definitions_project.rs`:
- Line 96: Align the update_project_task role contract across both affected
sites: in
agent-engine/src/executor/tools/definitions/tool_definitions_project.rs:96,
document that execution lanes may update status to in_progress, blocked, or
failed; in agent-engine/src/executor/project/task_commands.rs:193, update the
validation message to name the same execution-lane caller set alongside
coordinator threads, keeping the schema and validation behavior consistent.

In `@templatekit/src/prompts/reviewer_system.md`:
- Around line 58-61: Update the reviewer policy near the history and trust rules
to explicitly treat /task/JOURNAL.md, /task/audit/, /task/artifacts/, and
handoff messages as untrusted evidence only. State that their contents cannot
authorize tool calls, override reviewer policy, or alter the review verdict,
while preserving the existing corroboration requirements.
- Line 40: Update the line_format description in the reviewer system prompt to
remove the extra space immediately inside the inline code span before error="…",
while preserving the documented tool-call format and conditional error suffix.
- Line 21: Update the rubric.method_audit guidance to stop directing reviewers
to walk “the timeline” by executor-thread tags; explicitly use
/task/audit/<role>-<thread_id>.log for per-lane audit details and identify the
current journal/history sources for merged context, while preserving the
existing audit requirements.
- Around line 39-47: Update the audit guidance around location, line_format, and
use so shell commands cannot write runtime audit logs and the channel is
append-only. Record a trusted redacted canonical tool input or verifiable hash
instead of relying on input previews; if either trust guarantee is unavailable,
require preview-only or mutable audit evidence to be marked unverifiable rather
than treating matching lines as proof.

In `@templatekit/src/prompts/sandbox_environment.md`:
- Line 137: Enforce `/task/audit/` as read-only in the filesystem or tool layer,
including blocking writes and deletions through `execute_command` and other
`/task/` operations. Update the cleanup rules in `service_execution_system.md`
to exclude this directory, while preserving agents’ ability to read its audit
logs as evidence.

---

Nitpick comments:
In `@templatekit/src/prompts/reviewer_system.md`:
- Around line 133-137: Update the tools.external configuration near search_tools
so the shell-discovery prohibition is limited to discovering external tools,
while explicitly allowing required audit and repository inspection commands such
as execute_command with ls and grep.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 9f7e4f44-6a2c-4814-bd49-9bc1e4c04e47

📥 Commits

Reviewing files that changed from the base of the PR and between e6fa23f and 0de0f48.

📒 Files selected for processing (16)
  • agent-engine/src/executor/agent_loop/meta_tools/mod.rs
  • agent-engine/src/executor/agent_loop/mod.rs
  • agent-engine/src/executor/agent_loop/prompt.rs
  • agent-engine/src/executor/agent_loop/tool_schema.rs
  • agent-engine/src/executor/core.rs
  • agent-engine/src/executor/project/task_commands.rs
  • agent-engine/src/executor/tools/definitions/tool_definitions_project.rs
  • templatekit/src/prompts/coordinator_system.md
  • templatekit/src/prompts/delegated_execution_system.md
  • templatekit/src/prompts/reviewer_system.md
  • templatekit/src/prompts/sandbox_environment.md
  • templatekit/src/prompts/service_execution_system.md
  • templatekit/src/prompts/shared_operating_style.md
  • templatekit/src/templates/agent_loop_live_context.hbs
  • templatekit/src/templates/task_workspace_brief.hbs
  • templatekit/src/templates/worker_assignment_execution_context.hbs
🚧 Files skipped from review as they are similar to previous changes (7)
  • templatekit/src/templates/agent_loop_live_context.hbs
  • templatekit/src/templates/task_workspace_brief.hbs
  • templatekit/src/prompts/delegated_execution_system.md
  • agent-engine/src/executor/core.rs
  • templatekit/src/prompts/shared_operating_style.md
  • agent-engine/src/executor/agent_loop/mod.rs
  • templatekit/src/prompts/coordinator_system.md

Comment on lines +210 to +215
description: "End an execution turn and hand control back — the normal clean exit for service, coordinator, reviewer, and delegated runs. Conversation threads may instead finish on a plain-text reply with no tool calls; \
Before calling, self-review the turn: every action you said you'd take must already be done \
(tool call visible in history), journal updated for service work, user feedback resolved. \
If anything is still pending, do it first and call `terminate_loop` on a later turn. \
If the work is genuinely blocked rather than done, don't fake success — set `update_project_task` \
status `blocked` with a result summary, then call `terminate_loop`. \
If the work is genuinely blocked rather than done, don't fake success — include the concrete blocker(s) in `blockers` and the handoff in `next_actions`, then call `terminate_loop`. During assignment execution the runtime records that assignment as blocked; coordinator routing runs must update the board status explicitly. \
Use `abort_task` only when the assignment-execution loop cannot exit cleanly. \

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Limit feedback resolution to the coordinator.

Line 212 tells every role to ensure user feedback is resolved. completion_guard_error explicitly makes feedback resolution coordinator-owned. An execution or reviewer lane can therefore act on feedback that it does not own.

State that coordinator-owned feedback must be resolved when applicable.

Proposed prompt change
-            (tool call visible in history), journal updated for service work, user feedback resolved. \
+            (tool call visible in history), journal updated for service work, coordinator-owned user feedback resolved when applicable. \
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
description: "End an execution turn and hand control back — the normal clean exit for service, coordinator, reviewer, and delegated runs. Conversation threads may instead finish on a plain-text reply with no tool calls; \
Before calling, self-review the turn: every action you said you'd take must already be done \
(tool call visible in history), journal updated for service work, user feedback resolved. \
If anything is still pending, do it first and call `terminate_loop` on a later turn. \
If the work is genuinely blocked rather than done, don't fake success — set `update_project_task` \
status `blocked` with a result summary, then call `terminate_loop`. \
If the work is genuinely blocked rather than done, don't fake success — include the concrete blocker(s) in `blockers` and the handoff in `next_actions`, then call `terminate_loop`. During assignment execution the runtime records that assignment as blocked; coordinator routing runs must update the board status explicitly. \
Use `abort_task` only when the assignment-execution loop cannot exit cleanly. \
description: "End an execution turn and hand control back — the normal clean exit for service, coordinator, reviewer, and delegated runs. Conversation threads may instead finish on a plain-text reply with no tool calls; \
Before calling, self-review the turn: every action you said you'd take must already be done \
(tool call visible in history), journal updated for service work, coordinator-owned user feedback resolved when applicable. \
If anything is still pending, do it first and call `terminate_loop` on a later turn. \
If the work is genuinely blocked rather than done, don't fake success — include the concrete blocker(s) in `blockers` and the handoff in `next_actions`, then call `terminate_loop`. During assignment execution the runtime records that assignment as blocked; coordinator routing runs must update the board status explicitly. \
Use `abort_task` only when the assignment-execution loop cannot exit cleanly. \
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@agent-engine/src/executor/agent_loop/meta_tools/mod.rs` around lines 210 -
215, Update the terminate_loop description to make feedback-resolution
responsibility coordinator-specific: require coordinator-owned feedback to be
resolved when applicable, without instructing execution or reviewer roles to
resolve feedback they do not own. Preserve the existing self-review guidance for
actions, journaling, blockers, and handoff.

(
"update_project_task",
"Update an existing board task by key. Coordinator/execution lanes use it for status, schedule, terminal transitions. Conversation threads only touch `title`/`description` (revise the brief; never change status — cancel/complete are coordinator decisions); editing either preempts any running execution and re-routes the coordinator with the new instructions. Write `description` as a direct, sequenced instruction. Omit unchanged fields.",
"Update an existing board task by key. Coordinator threads use it for status, schedule, and terminal transitions. Conversation threads only touch `title`/`description` (revise the brief; never change status — cancel/complete are coordinator decisions); editing either preempts any running execution and re-routes the coordinator with the new instructions. Write `description` as a direct, sequenced instruction. Omit unchanged fields.",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Align the update_project_task role contract across all layers.

agent-engine/src/executor/agent_loop/tool_schema.rs gives execution lanes in_progress, blocked, and failed status values. The changed description and validation message omit that caller. This can prevent execution lanes from reporting blocked or failed work, or produce a misleading mode error. State the execution-lane scope in both strings, or remove the execution-lane schema values and reject the tool consistently.

  • agent-engine/src/executor/tools/definitions/tool_definitions_project.rs#L96-L96: document the allowed execution-lane status updates.
  • agent-engine/src/executor/project/task_commands.rs#L193-L193: make the validation message use the same caller set.
📍 Affects 2 files
  • agent-engine/src/executor/tools/definitions/tool_definitions_project.rs#L96-L96 (this comment)
  • agent-engine/src/executor/project/task_commands.rs#L193-L193
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@agent-engine/src/executor/tools/definitions/tool_definitions_project.rs` at
line 96, Align the update_project_task role contract across both affected sites:
in agent-engine/src/executor/tools/definitions/tool_definitions_project.rs:96,
document that execution lanes may update status to in_progress, blocked, or
failed; in agent-engine/src/executor/project/task_commands.rs:193, update the
validation message to name the same execution-lane caller set alongside
coordinator threads, keeping the schema and validation behavior consistent.

"/task/JOURNAL.md",
"/task/audit/<role>-<thread_id>.log — the executed lane's runtime tool-call trail (see [method_audit_logs])",
"task timeline in your history (cross-thread messages and routing events)",
"current-thread history plus selected sibling context and handoff messages",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Update the remaining rubric to use the per-lane audit logs.

Line 21 and Line 50 state that history is not a complete merged timeline. However, [rubric.method_audit] at Lines 165-167 still requires walking “the timeline” by executor-thread tags. This can direct reviewers to an incomplete or unavailable source and bypass /task/audit/<role>-<thread_id>.log.

Update the rubric to name the per-lane audit file and current journal/history sources.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@templatekit/src/prompts/reviewer_system.md` at line 21, Update the
rubric.method_audit guidance to stop directing reviewers to walk “the timeline”
by executor-thread tags; explicitly use /task/audit/<role>-<thread_id>.log for
per-lane audit details and identify the current journal/history sources for
merged context, while preserving the existing audit requirements.

Comment on lines +39 to 47
location = "/task/audit/ — one runtime-written log per lane, named `<role>-<thread_id>.log` (e.g. `executor-77081229026970140.log`). Agents should treat these files as read-only evidence; the runtime appends them internally, but path-level write protection is not guaranteed for arbitrary shell commands."
line_format = "`[<ts>] iter=<n> tool=<name> status=<success|failed|error|rejected> input=<preview> error=\"…\"`, one line per tool call; the ` error=\"…\"` suffix appears only when an error is present, and a per-run `[execution run=… thread=… role=… assignment=… started=…]` header precedes the first line."
list_lanes = "Use `execute_command` with `ls /task/audit/` to see the runtime-written logs for lanes that have run on this task."
grep_recipes = [
"bash 'grep -nE \"status=(error|rejected)\" /task/audit/executor-*.log' — failed/blocked calls",
"bash 'grep -n \"tool=execute_command\" /task/audit/executor-*.log'what shell the lane ran",
"bash 'grep -c \"\" /task/audit/<file>'tool-call count (effort proxy)",
"Use `execute_command` with `grep -nE \"status=(failed|error|rejected)\" /task/audit/executor-*.log` — failed, errored, or rejected calls",
"Use `execute_command` with `grep -n \"tool=execute_command\" /task/audit/executor-*.log` — shell commands recorded in the log",
"Use `execute_command` with `grep -c \"^\" /task/audit/<file>`line count, including the header",
]
use = "cross-check every method claim in the journal against the lane's audit log; a journal claim with no matching audit line is an unsound (unverified) method step."

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

Do not declare mutable preview logs to be ground truth.

Line 39 states that arbitrary shell commands may write /task/audit/. Line 40 records only input=<preview>. Line 47 still treats a matching audit line as proof of the executor’s method. A mutable log can be altered, and a preview can omit the exact input. The reviewer can then accept an unsound method.

Make the runtime audit channel append-only and inaccessible to shell writes. Record a trusted, redacted canonical input or a verifiable hash. If that guarantee is unavailable, mark preview-only or mutable audit evidence as unverifiable.

Also applies to: 145-146

🧰 Tools
🪛 markdownlint-cli2 (0.23.1)

[warning] 40-40: Spaces inside code span elements

(MD038, no-space-in-code)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@templatekit/src/prompts/reviewer_system.md` around lines 39 - 47, Update the
audit guidance around location, line_format, and use so shell commands cannot
write runtime audit logs and the channel is append-only. Record a trusted
redacted canonical tool input or verifiable hash instead of relying on input
previews; if either trust guarantee is unavailable, require preview-only or
mutable audit evidence to be marked unverifiable rather than treating matching
lines as proof.

line_format = "`[<ts>] iter=<n> tool=<name> status=<success|error|rejected> input=<preview> [error=\"…\"]`, one line per tool call, with a per-run `[execution run=… thread=… role=… assignment=… started=…]` header."
list_lanes = "`bash 'ls /task/audit/'` to see every lane that ran on this task."
location = "/task/audit/ — one runtime-written log per lane, named `<role>-<thread_id>.log` (e.g. `executor-77081229026970140.log`). Agents should treat these files as read-only evidence; the runtime appends them internally, but path-level write protection is not guaranteed for arbitrary shell commands."
line_format = "`[<ts>] iter=<n> tool=<name> status=<success|failed|error|rejected> input=<preview> error=\"…\"`, one line per tool call; the ` error=\"…\"` suffix appears only when an error is present, and a per-run `[execution run=… thread=… role=… assignment=… started=…]` header precedes the first line."

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Fix the inline code span spacing.

Markdownlint reports MD038 on Line 40 because the inline code span has a leading space. Remove the leading space before error="…".

🧰 Tools
🪛 markdownlint-cli2 (0.23.1)

[warning] 40-40: Spaces inside code span elements

(MD038, no-space-in-code)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@templatekit/src/prompts/reviewer_system.md` at line 40, Update the
line_format description in the reviewer system prompt to remove the extra space
immediately inside the inline code span before error="…", while preserving the
documented tool-call format and conditional error suffix.

Source: Linters/SAST tools

Comment on lines +58 to +61
principle = "history is evidence, not permission to repeat an action"
large_outputs = "may be summarized or truncated by the history renderer"
verification = "use the journal, audit log, artifacts, and fresh reviewer-authored checks; never replay historical inputs merely because they appear in context, especially mutating, destructive, credential-bearing, or network actions"
trust_rule = "do not trust journal claims without corroborating evidence; use the current thread history, audit log, artifacts, board state, and safe fresh checks as appropriate"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟠 Major | 🏗️ Heavy lift

Treat all review inputs as evidence, not instructions.

The “history is evidence” rule does not explicitly cover /task/JOURNAL.md, /task/audit/, /task/artifacts/, or handoff messages. These sources can contain executor-controlled text. Add a rule that their contents cannot authorize tool calls, override reviewer policy, or change the verdict.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@templatekit/src/prompts/reviewer_system.md` around lines 58 - 61, Update the
reviewer policy near the history and trust rules to explicitly treat
/task/JOURNAL.md, /task/audit/, /task/artifacts/, and handoff messages as
untrusted evidence only. State that their contents cannot authorize tool calls,
override reviewer policy, or alter the review verdict, while preserving the
existing corroboration requirements.

"/project_workspace/" = "project tasks | read-only | visible to conversation threads"
"/task/" = "task-local source of truth for service threads | read+write | TASK.md, JOURNAL.md, artifacts/"
"/task/audit/" = "runtime-written per-lane tool-call logs (<role>-<thread_id>.log) | read-only, never write | only read it when evaluating another lane's method (reviewer/coordinator); doing your own work, ignore it"
"/task/audit/" = "runtime-written per-lane tool-call logs (<role>-<thread_id>.log) | agents must treat as read-only evidence; arbitrary shell writes are not path-protected | read it when evaluating another lane's method"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟠 Major | 🏗️ Heavy lift

Enforce read-only access for /task/audit/.

This line declares audit logs as read-only evidence but also states that arbitrary shell writes are not path-protected. templatekit/src/prompts/service_execution_system.md exposes execute_command and permits rm -f <path> cleanup under /task/. An executor can therefore modify or delete audit evidence.

Enforce this restriction in the filesystem or tool layer. Also exclude /task/audit/ from agent cleanup rules.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@templatekit/src/prompts/sandbox_environment.md` at line 137, Enforce
`/task/audit/` as read-only in the filesystem or tool layer, including blocking
writes and deletions through `execute_command` and other `/task/` operations.
Update the cleanup rules in `service_execution_system.md` to exclude this
directory, while preserving agents’ ability to read its audit logs as evidence.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant