Repository navigation
Conversation
Regeneration-Prompt: | Move the reasoning-only and empty-response retry behavior added in PR #66167 out of the OpenAI-specific runner guard and behind the provider plugin boundary. Keep replay-safety, liveness, retry-loop control, and incomplete-turn fallback behavior in core pi-embedded-runner code, but let provider plugins declare whether their model families support reasoning-only and/or empty-response continuation plus the retry budgets. Preserve the current OpenAI and OpenAI Codex behavior, add Anthropic as a second provider consumer for reasoning-only recovery, update the provider runtime tests and runner harness/tests, and refresh the public provider-plugin SDK docs and API baseline hash for the new hook.
Regeneration-Prompt: | After opening PR #66233 for the provider-owned incomplete-turn recovery refactor, add the required changelog entry under ## Unreleased -> ### Fixes. Keep the entry append-only, reference the new PR number, and describe that replay-safe reasoning-only and empty-response continuation moved behind provider hooks so providers can opt in without runner special cases, with Anthropic using the same seam for reasoning-only recovery.
Greptile SummaryThis PR cleanly moves reasoning-only and empty-response incomplete-turn recovery out of the OpenAI-specific runner guard and behind the
Confidence Score: 5/5Safe to merge — all remaining findings are P2 style/ergonomics concerns with no correctness impact. Core retry control flow, replay-safety guards, and liveness state are unchanged. Provider hooks correctly gate on recoveryRule?.enabled === true, so providers without a policy produce no retries. Both OpenAI and Anthropic policies are straightforward and well-tested. The two open findings (missing ProviderIncompleteTurnRetryRule re-export and duplicated stripProviderPrefix) are P2 style issues that do not affect runtime behavior. No files require blocking attention; extensions/anthropic/incomplete-turn-policy.ts and extensions/openai/incomplete-turn-policy.ts share a duplicated helper worth tracking. Prompt To Fix All With AIThis is a comment left during a code review.
Path: extensions/anthropic/incomplete-turn-policy.ts
Line: 7-11
Comment:
**`stripProviderPrefix` duplicated across extension files**
This helper is identical to the one in `extensions/openai/incomplete-turn-policy.ts` (lines 9–13). The CLAUDE.md plugin boundary rules call for centralising shared helpers before a second consumer appears. Now that two consumers exist, extracting this to a shared SDK seam (or a small shared utility module both extensions can import) would prevent the two implementations from drifting.
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: src/plugin-sdk/plugin-entry.ts
Line: 104-105
Comment:
**`ProviderIncompleteTurnRetryRule` not re-exported from public SDK**
`ProviderIncompleteTurnRecoveryPolicy` (which is exported) contains two fields typed as `ProviderIncompleteTurnRetryRule`, but the sub-type itself is not re-exported. TypeScript's structural typing means plugin authors can still construct correct return values without importing the type, but they can't explicitly annotate intermediate `ProviderIncompleteTurnRetryRule` variables. Adding it alongside the two already-exported types would complete the public surface and is consistent with how all fields of exported policy types are accessible.
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "docs: note provider-owned incomplete-tur..." | Re-trigger Greptile |
| function stripProviderPrefix(modelId: string): string { | ||
| const trimmed = modelId.trim(); | ||
| const match = /^([^/:]+)[/:](.+)$/.exec(trimmed); | ||
| return normalizeLowercaseStringOrEmpty(match?.[2] ?? trimmed); | ||
| } |
There was a problem hiding this comment.
stripProviderPrefix duplicated across extension files
This helper is identical to the one in extensions/openai/incomplete-turn-policy.ts (lines 9–13). The CLAUDE.md plugin boundary rules call for centralising shared helpers before a second consumer appears. Now that two consumers exist, extracting this to a shared SDK seam (or a small shared utility module both extensions can import) would prevent the two implementations from drifting.
Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/anthropic/incomplete-turn-policy.ts
Line: 7-11
Comment:
**`stripProviderPrefix` duplicated across extension files**
This helper is identical to the one in `extensions/openai/incomplete-turn-policy.ts` (lines 9–13). The CLAUDE.md plugin boundary rules call for centralising shared helpers before a second consumer appears. Now that two consumers exist, extracting this to a shared SDK seam (or a small shared utility module both extensions can import) would prevent the two implementations from drifting.
How can I resolve this? If you propose a fix, please make it concise.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| ProviderIncompleteTurnRecoveryContext, | ||
| ProviderIncompleteTurnRecoveryPolicy, |
There was a problem hiding this comment.
ProviderIncompleteTurnRetryRule not re-exported from public SDK
ProviderIncompleteTurnRecoveryPolicy (which is exported) contains two fields typed as ProviderIncompleteTurnRetryRule, but the sub-type itself is not re-exported. TypeScript's structural typing means plugin authors can still construct correct return values without importing the type, but they can't explicitly annotate intermediate ProviderIncompleteTurnRetryRule variables. Adding it alongside the two already-exported types would complete the public surface and is consistent with how all fields of exported policy types are accessible.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/plugin-sdk/plugin-entry.ts
Line: 104-105
Comment:
**`ProviderIncompleteTurnRetryRule` not re-exported from public SDK**
`ProviderIncompleteTurnRecoveryPolicy` (which is exported) contains two fields typed as `ProviderIncompleteTurnRetryRule`, but the sub-type itself is not re-exported. TypeScript's structural typing means plugin authors can still construct correct return values without importing the type, but they can't explicitly annotate intermediate `ProviderIncompleteTurnRetryRule` variables. Adding it alongside the two already-exported types would complete the public surface and is consistent with how all fields of exported policy types are accessible.
How can I resolve this? If you propose a fix, please make it concise.There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cbc6276a4f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| workspaceDir: params.workspaceDir, | ||
| context: { | ||
| config: params.config, | ||
| agentDir, | ||
| workspaceDir: params.workspaceDir, |
There was a problem hiding this comment.
Pass resolved workspace into recovery-policy hook
This new hook call forwards params.workspaceDir, but runEmbeddedPiAgent normally derives a resolvedWorkspace when the caller omits that field. In those common runs, resolveIncompleteTurnRecoveryPolicy receives ctx.workspaceDir as undefined, so provider plugins that need workspace-scoped config/files to decide recovery behavior can silently return no policy and disable retries unexpectedly. Use the already-resolved workspace path here (both for hook resolution and the hook context) to keep this seam consistent with other provider-runtime hook calls.
Useful? React with 👍 / 👎.
🔒 Aisle Security AnalysisWe found 2 potential security issue(s) in this PR:
1. 🟡 Unhandled exception in provider plugin hook can crash run loop (incomplete turn recovery policy)
Description
Vulnerable code: return (
resolveProviderHookPlugin(params)?.resolveIncompleteTurnRecoveryPolicy?.(params.context) ??
undefined
);RecommendationWrap provider plugin hook execution in a defensive Example: export function resolveProviderIncompleteTurnRecoveryPolicyWithPlugin(params: {
provider: string;
config?: OpenClawConfig;
workspaceDir?: string;
env?: NodeJS.ProcessEnv;
context: ProviderIncompleteTurnRecoveryContext;
}): ProviderIncompleteTurnRecoveryPolicy | undefined {
try {
return (
resolveProviderHookPlugin(params)?.resolveIncompleteTurnRecoveryPolicy?.(params.context) ??
undefined
);
} catch (err) {
// TODO: replace with structured logging/telemetry
log.warn(
`[provider-hook] resolveIncompleteTurnRecoveryPolicy failed for provider=${params.provider}: ${String(err)}`,
);
return undefined;
}
}If the project has an established pattern for safe plugin execution (e.g., a shared wrapper), use it consistently across all provider hook invocations. 2. 🟡 Incomplete-turn auto-retry may replay side-effecting tool calls due to weak side-effect detection and provider-enabled recovery
DescriptionThe embedded runner decides whether an incomplete turn is replay-safe using a heuristic that only considers tool names plus a couple of special cases. With this change, providers can enable reasoning-only / empty-response recovery via If a tool causes external side effects but its name is not recognized by Why this is security-relevant:
Vulnerable code (replay-safety classification): const hadMutatingTools = params.toolMetas.some((t) => isLikelyMutatingToolName(t.toolName));
const hadPotentialSideEffects =
hadMutatingTools || params.didSendViaMessagingTool || (params.successfulCronAdds ?? 0) > 0;With provider-enabled recovery, any misclassification here can lead to duplicated real-world actions on retry. RecommendationFail closed for replay safety and/or require explicit tool-side metadata. Options (can be combined):
Example approach (sketch): // during tool registration / schema normalization
type ToolSafety = { sideEffecting: boolean };
// when building replay metadata
const hadPotentialSideEffects = params.toolMetas.some(t => t.safety?.sideEffecting ?? true);This ensures automatic retries cannot occur after any tool that is not explicitly marked replay-safe. Analyzed PR: #66233 at commit Last updated on: 2026-04-14T00:33:58Z |
Regeneration-Prompt: | After opening PR openclaw#66233 for the provider-owned incomplete-turn recovery refactor, add the required changelog entry under ## Unreleased -> ### Fixes. Keep the entry append-only, reference the new PR number, and describe that replay-safe reasoning-only and empty-response continuation moved behind provider hooks so providers can opt in without runner special cases, with Anthropic using the same seam for reasoning-only recovery.
Summary
pi-embedded-runner, gated by an OpenAI-specific helper instead of the provider plugin boundary.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Root Cause (if applicable)
Regression Test Plan (if applicable)
src/agents/pi-embedded-runner/run.incomplete-turn.test.ts,src/plugins/provider-runtime.test.ts,extensions/openai/index.test.ts,extensions/anthropic/index.test.tsUser-visible / Behavior Changes
Diagram (if applicable)
Security Impact (required)
Yes, explain risk + mitigation:Repro + Verification
Environment
Steps
Expected
Actual
Evidence
Attach at least one:
Human Verification (required)
pnpm build.Review Conversations
Compatibility / Migration
Risks and Mitigations
ProviderPlugin/provider-runtimewith focused boundary coverage.