Agent Phases

Phase 4: Feedback & Learning

After Testonaut opens a pull request, the system moves from generation into review collaboration: it reads PR comments, responds to reviewer commands, applies scoped fixes, verifies again, and turns recurring feedback into proposed project or agent guidelines.

This phase is intentionally conservative. Reviewer text is treated as feedback, not as unchecked system instructions. Testonaut can fix the PR or propose a learning rule, but the durable knowledge update is always raised through a separate human-reviewed PR.

Phase 4 end-to-end flow: reviewer comments are classified and routed to scoped fixes, explanations, acknowledgements, or guideline proposals
The feedback loop — bounded, auditable, and always ending in human review.

What this phase owns

ResponsibilityWhat happensOutput
PR comment monitoringRead pull request threads from Azure DevOps or GitHub through the VCS adapter.Actionable reviewer comments are identified.
Command handlingDetect @testonaut, @update-knowledge, and @update-agent commands.The correct feedback or learning lane is selected.
Feedback fixesApply the smallest safe change requested by the reviewer.Updated branch plus a PR reply with verification result.
Explanations and acknowledgementsReply when the reviewer asks why something was done or confirms the work.Clear comment back on the PR thread.
Learning proposalsConvert explicit reviewer rules into Markdown guideline updates.Separate review PR editing guideline .md files.
Loop safety and auditabilityTrack responder iterations, skip answered threads, avoid replying to itself, emit audit records.Bounded, traceable PR automation.

PR responder command

testonaut respond-to-pr --repo <path> --pr <id> --issue <KEY> [options]
OptionPurpose
--repo <path>Target repository that contains the implementation PR.
--pr <id>Pull request id to inspect.
--issue <KEY>Jira issue key connected to the PR.
--stack <id>Selects a configured stack when the repo has more than one.
--verify <command>Overrides the stack verify command for this response run.
--mention <handle>Overrides the PR mention handle. Defaults to the repo config, usually @testonaut.
--max-iterations <n>Overrides the PR-wide response budget.
--dry-runClassifies and reports only. Does not edit files, verify, or post comments.
--config <path>Loads runtime configuration overrides.

The command resolves the VCS adapter from the repository remote — Azure DevOps and GitHub are supported through the shared adapter interface, used to list PR threads, post replies, and raise learning proposal PRs.

Reviewer commands

@testonaut

Use when a reviewer wants Testonaut to react directly on the implementation PR:

@testonaut use the existing LoginPage helper instead of creating a new helper.
@testonaut why did you add a separate scenario for the cancellation case?
@testonaut thanks, looks good.

The responder classifies the comment into one of four intents:

IntentTypical wordingBehavior
fixfix, update, change, correct, adjust, rework, add, remove, wrong, should, failingRuns the feedback-scoped code-agent flow and verifies again.
explainwhy, what, how, explain, clarify, ?Posts a written explanation without changing files.
acknowledgethanks, thank you, lgtm, looks good, okPosts a short acknowledgement.
ignoreNo actionable commandTakes no action.

@update-knowledge

Use when the reviewer wants a project-specific rule captured for the target repository:

@update-knowledge Prefer existing page-object helpers before adding new Playwright locators.

This creates or updates a Markdown file under .agents/guidelines/<category>.md in the target repository. The change is raised as a separate PR — it is not merged automatically and does not silently modify the implementation branch.

@update-agent

Use when the reviewer wants to propose a general Testonaut behavior change that should apply beyond the current project:

@update-agent When a repository has Cucumber step definitions, always inspect them before writing new step text.

This targets the Testonaut agent repository (proposed-guidelines/<category>.md), not the project repository. The runtime must know where the Testonaut checkout lives via TESTONAUT_AGENT_REPO. If the variable is missing, the responder refuses @update-agent cleanly and posts a clear reply.

Feedback-scoped fix flow

When a comment is classified as fix, Testonaut does not rerun the whole implementation phase. It creates a narrow repair prompt that includes the Jira issue key, the target repository root, the exact reviewer feedback, the reviewer name when available, the verify command, and the files changed by the original implementation. The prompt enforces the feedback boundary:

Feedback-scoped fix flow: reviewer comment becomes a narrow repair prompt, the code agent applies the smallest change, then verification runs
The fix lane: reviewer feedback becomes a narrow repair prompt, the smallest safe change is applied, and verification runs again before the reply.
  • make the smallest change that addresses the review comment;
  • do not refactor unrelated code;
  • do not modify product code;
  • treat .feature files as the source of truth unless the reviewer explicitly asks to change the test design;
  • reuse existing helpers, fixtures, page objects, and selector conventions;
  • do not weaken assertions, skip scenarios, or hide failures to make verification pass.

The reply summarizes what changed, which files changed, whether verification passed, and the verification exit code. If verification still fails, Testonaut includes enough output context for the reviewer to understand what remains.

Verification after a fix

The verification command comes from the selected stack in .agents/testonaut.config.json, unless overridden by --verify. Phase 4 validates the same path that humans and CI care about — if the project has a Docker-backed test stack from Phase 3, the responder can reuse that configured verify command when applying PR feedback.

Verification after a fix reuses the stack verify command from the repository config
Post-fix verification reuses the stack's configured verify command — the same path humans and CI rely on.

Learning and Markdown guideline updates

Learning is separated from immediate PR repair. A reviewer can ask Testonaut to capture a durable rule, but Testonaut only proposes that rule through a reviewable Markdown change. The classifier decides which file should receive the proposed rule:

Learning flow: update commands are classified into categories and proposed as Markdown guideline changes in a separate PR
Review-first learning: @update-knowledge and @update-agent commands become categorized Markdown proposals raised as separate, human-reviewed PRs.
CategorySignalsTarget file
selectorselector, locator, getByRole, data-testid, CSS, XPathselectors.md
timingwait, sleep, hard-coded delay, pollingwaiting.md
test-datahard-coded IDs, factories, fixtures, seed data, tenant/account IDstest-data.md
assertionassertion, expectation, verification, checksassertions.md
conventionnaming, style, pattern, always, never, preferconventions.md
flakyflaky, intermittent, retry, passed on retryflaky-tests.md
infrastructuretimeout, network, 5xx, rate limit, environment, CI runnerinfrastructure.md
otherno specific category matchedgeneral.md

Project-level rules live under .agents/guidelines/; agent-level rules under proposed-guidelines/. If a guideline file does not exist, Testonaut creates it with a heading and provenance note. If the same proposed rule is already present, it skips the duplicate edit.

Why learning is proposed through PRs

Reviewer feedback can contain useful rules, but it is still untrusted input. Phase 4 uses a review-first learning model:

  • no automatic merge into the project guidelines;
  • no automatic merge into Testonaut's own packaged guidelines;
  • no hidden edits to the implementation branch;
  • each rule is visible as Markdown;
  • every proposal has provenance back to PR feedback;
  • humans decide whether the rule is correct, broadly applicable, and safe.

This keeps learning useful without letting a single PR comment permanently change agent behavior without review.

Loop safety

Loop safety decision flow: skip own comments, skip answered threads, honor iteration budget, support dry-run
Loop safety: own-comment and last-reply detection, hidden iteration markers, the per-PR iteration budget, and dry-run mode keep the responder bounded.
Safety mechanismHow it works
Own-comment detectionTestonaut skips comments it wrote itself.
Last-reply detectionIf the latest comment in a thread is already from Testonaut, the thread is skipped.
Hidden iteration markerReplies include a marker like testonaut-bot:iteration:N.
Iteration budgetpr.maxIterationsPerPr limits response cycles on a PR; --max-iterations overrides.
Dry-run mode--dry-run reports what would happen without editing files or posting comments.
Adapter capability checksIf the VCS adapter cannot list threads or post comments, the responder reports that it cannot run.

Audit and observability

ActionMeaning
pr.fix-appliedA PR feedback command resulted in a code/test change attempt.
rule.proposedA reviewer command resulted in a proposed Markdown guideline PR.

The audit path is under the local out directory for the responder run, and configured redaction patterns are applied before writing audit details.

Operational requirements

  • a supported VCS remote — currently Azure DevOps or GitHub;
  • a token for the VCS provider, such as AZURE_DEVOPS_PAT or GITHUB_TOKEN;
  • a valid .agents/testonaut.config.json with PR settings and at least one stack verify command;
  • local credentials or configured push auth if Testonaut needs to push proposal branches;
  • TESTONAUT_AGENT_REPO when using @update-agent.
{
  "pr": {
    "mention": "@testonaut",
    "maxIterationsPerPr": 5
  }
}

How this closes the loop

A human reviews the generated PR; Testonaut responds only to explicit commands; small requested fixes are applied and verified in the same PR; durable rules are proposed as Markdown guideline changes in a separate PR; and human review decides which learnings become active for future runs. The result is a safe learning mechanism where repeated review guidance becomes reusable project or agent knowledge without bypassing human ownership.