From d2784eeab36065a60ba96fb7b4b5eed7a26b9c37 Mon Sep 17 00:00:00 2001 From: Chris Huber Date: Sun, 15 Nov 2026 14:46:51 +0000 Subject: [PATCH] feat(workflow): expose max_turns and time_budget_ms, default 40 turns --- .github/workflows/README.md | 2 +- .github/workflows/maintain-docs.yml | 10 ++++++++++ README.md | 2 ++ tests/validate-wp-codebox-run-agent-task-contract.php | 4 +++- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/.github/workflows/README.md b/.github/workflows/README.md index 6884657..9424b8b 100644 --- a/.github/workflows/README.md +++ b/.github/workflows/README.md @@ -1,6 +1,6 @@ # Docs Agent Workflows -`maintain-docs.yml` is the consumer-facing reusable workflow for scheduled upkeep. Consumer repositories pass product-level inputs such as `audience`, `require_pr`, `base_ref`, `docs_branch`, `writable_paths`, `context_repositories`, `bootstrap_contract`, `source_delta`, `validation_dependencies`, `verification_commands`, `drift_checks`, `prompt`, `run_agent`, and `dry_run`. +`maintain-docs.yml` is the consumer-facing reusable workflow for scheduled upkeep. Consumer repositories pass product-level inputs such as `audience`, `require_pr`, `base_ref`, `docs_branch`, `writable_paths`, `context_repositories`, `bootstrap_contract`, `source_delta`, `validation_dependencies`, `verification_commands`, `drift_checks`, `prompt`, `run_agent`, `dry_run`, `max_turns`, and `time_budget_ms`. The consumer workflow supports separate lanes for technical docs, user docs, and live skills maintenance. Use `audience: skills` with skills/package writable paths instead of broad docs paths. diff --git a/.github/workflows/maintain-docs.yml b/.github/workflows/maintain-docs.yml index bb89849..8f526bc 100644 --- a/.github/workflows/maintain-docs.yml +++ b/.github/workflows/maintain-docs.yml @@ -73,6 +73,14 @@ env: description: Validate the prepared Docs Agent task without starting a live agent run. type: boolean default: false + max_turns: + description: Maximum agent turns. Reading a large source tree before writing needs more than WP Codebox's default of 12. + type: number + default: 40 + time_budget_ms: + description: Agent run time budget in milliseconds. + type: number + default: 1800000 secrets: OPENAI_API_KEY: description: Optional OpenAI credential used for live Docs Agent runs. @@ -374,6 +382,8 @@ jobs: callback_data: ${{ needs.prepare.outputs.recipe_json }} run_agent: ${{ inputs.run_agent }} dry_run: ${{ inputs.dry_run }} + max_turns: ${{ inputs.max_turns }} + time_budget_ms: ${{ inputs.time_budget_ms }} secrets: OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} ACCESS_TOKEN: ${{ secrets.PUBLISH_TOKEN || github.token }} diff --git a/README.md b/README.md index db91e3b..407b4af 100644 --- a/README.md +++ b/README.md @@ -103,6 +103,8 @@ The consumer API is product-level. Consumer repositories configure the documenta | `model` | `gpt-5.5` | OpenAI model id for the live run. Defaults to the WP Codebox contract default, so omitting it changes nothing. | | `run_agent` | `true` | Set `false` to skip after deterministic preflight says docs are current. | | `dry_run` | `false` | Set `true` to validate the prepared task without starting a live agent run. | +| `max_turns` | `40` | Maximum agent turns. WP Codebox defaults to 12, which a large source tree can use up on reading before any write. | +| `time_budget_ms` | `1800000` | Agent run time budget in milliseconds. | `verification_commands` and `drift_checks` are executable caller inputs. Docs Agent appends its own completion-contract check as a separate drift entry after them. The target repository remains the only writable PR boundary. diff --git a/tests/validate-wp-codebox-run-agent-task-contract.php b/tests/validate-wp-codebox-run-agent-task-contract.php index 1a45830..3a5eadb 100644 --- a/tests/validate-wp-codebox-run-agent-task-contract.php +++ b/tests/validate-wp-codebox-run-agent-task-contract.php @@ -160,7 +160,7 @@ $input = $contract['inputs'][ $name ] ?? null; $assert( is_array( $input ), "Docs Agent passes producer input {$name}, which is absent from the producer schema." ); $type = $input['type'] ?? null; - $actual_type = preg_match( '/^(true|false)$/', $value ) === 1 || in_array( $name, array( 'success_requires_pr', 'run_agent', 'dry_run' ), true ) ? 'boolean' : ( is_numeric( $value ) ? 'number' : 'string' ); + $actual_type = preg_match( '/^(true|false)$/', $value ) === 1 || in_array( $name, array( 'success_requires_pr', 'run_agent', 'dry_run' ), true ) ? 'boolean' : ( is_numeric( $value ) || in_array( $name, array( 'max_turns', 'time_budget_ms' ), true ) ? 'number' : 'string' ); $assert( $type === $actual_type, "Docs Agent input {$name} has {$actual_type} shape; producer requires {$type}." ); } @@ -217,6 +217,8 @@ $assert( preg_match( '/secrets:\n(?: [A-Z_]+:\n(?: .*\n)* required: (?:true|false)\n)* EXTERNAL_PACKAGE_SOURCE_POLICY:\n(?: .*\n)* required: true/m', $workflow ) === 1, 'Docs Agent must require EXTERNAL_PACKAGE_SOURCE_POLICY from reusable-workflow callers.' ); $assert( '${{ inputs.run_agent }}' === ( $caller_inputs['run_agent'] ?? null ), 'Docs Agent must delegate run_agent so WP Codebox reports deterministic skipped status.' ); $assert( '${{ inputs.dry_run }}' === ( $caller_inputs['dry_run'] ?? null ), 'Docs Agent must delegate dry_run so WP Codebox validates without starting a live run.' ); +$assert( '${{ inputs.max_turns }}' === ( $caller_inputs['max_turns'] ?? null ), 'Docs Agent must delegate max_turns; the producer default of 12 turns ends source-heavy runs before any write.' ); +$assert( '${{ inputs.time_budget_ms }}' === ( $caller_inputs['time_budget_ms'] ?? null ), 'Docs Agent must delegate time_budget_ms alongside max_turns.' ); $assert( preg_match( '/validation_dependencies:\n description: Optional caller-owned command that installs dependencies needed before validation\.\n type: string\n default: ""/', $workflow ) === 1, 'Docs Agent must expose validation_dependencies as an optional empty-string reusable-workflow input.' ); $assert( preg_match( '/require_pr:\n description: Require a published target-repository pull request for successful maintenance\.\n type: boolean\n default: false/', $workflow ) === 1, 'Docs Agent must expose require_pr as an optional boolean reusable-workflow input.' ); $assert( preg_match( '/\n if: inputs\.run_agent\n/', $workflow ) !== 1, 'Docs Agent must not skip the producer job outside the producer contract.' );