Skip to content

feat(agent): 1 retry change for realize functions.#1282

Merged
samchon merged 6 commits into
mainfrom
feat/retry
Apr 7, 2026
Merged

feat(agent): 1 retry change for realize functions.#1282
samchon merged 6 commits into
mainfrom
feat/retry

Conversation

@samchon

@samchon samchon commented Apr 7, 2026

Copy link
Copy Markdown
Member

This pull request refactors the realization correction workflow to introduce a unified retry mechanism and standardized result reporting for function realization steps. The main improvements are the addition of a generic result type to consistently report success/failure for each function, and the introduction of a reusable retry orchestration utility. This leads to more robust error handling and clearer control flow across collector, operation, and transformer realization processes.

Core infrastructure changes:

  • Added a new interface, IAutoBeRealizeFunctionResult, to encapsulate the success state and value of each realized function.
  • All core "correct overall" functions now return arrays of IAutoBeRealizeFunctionResult instead of plain function arrays, ensuring standardized reporting of individual function results. [1] [2] [3] [4] [5] [6] [7] [8] F0cd17e3L20R21, [9] [10] [11] [12]

Retry orchestration improvements:

  • Introduced a new utility, orchestrateRealizeCorrectWithRetry, which encapsulates the logic for first-attempt realization, result filtering, and retrying failed functions, returning only successful results.
  • Updated collector, operation, and transformer realization entry points to use the new retry utility, simplifying their control flow and ensuring consistent retry behavior. [1] [2] [3] [4] [5] [6]

Selective retry targeting:

  • Enhanced orchestrateRealizeOperationWrite to accept an optional targetEndpoints parameter, allowing retries to focus only on failed endpoints.

These changes collectively improve error handling, code reuse, and maintainability in the realization orchestration logic.

@samchon samchon self-assigned this Apr 7, 2026
@samchon samchon added this to WrtnLabs Apr 7, 2026
@samchon samchon added the enhancement New feature or request label Apr 7, 2026
@samchon samchon marked this pull request as ready for review April 7, 2026 22:54
Copilot AI review requested due to automatic review settings April 7, 2026 22:54
@samchon samchon merged commit 6b60da0 into main Apr 7, 2026
9 checks passed
@samchon samchon deleted the feat/retry branch April 7, 2026 22:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the “realize” correction workflow to standardize per-function success reporting and centralize retry orchestration across collector/operation/transformer realization.

Changes:

  • Introduces IAutoBeRealizeFunctionResult and updates overall-correction entry points to return per-function success/failure results.
  • Adds orchestrateRealizeCorrectWithRetry and updates collector/operation/transformer orchestration to use a unified 1-retry flow.
  • Enhances operation rewrite to optionally target only failed endpoints; updates prompts to enforce null-guards and non-null DB default handling guidance.

Reviewed changes

Copilot reviewed 16 out of 17 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
website/src/content/_meta.ts Renames the “benchmark” page title text.
packages/agent/src/orchestrate/realize/structures/IAutoBeRealizeFunctionResult.ts Adds a common result wrapper for realized functions.
packages/agent/src/orchestrate/realize/programmers/AutoBeRealizeTransformerProgrammer.ts Adds HttpException to generated transformer imports to support new null-guard guidance.
packages/agent/src/orchestrate/realize/orchestrateRealizeTransformerCorrectOverall.ts Updates transformer overall-correction to return standardized per-function results.
packages/agent/src/orchestrate/realize/orchestrateRealizeTransformer.ts Switches transformer realization to the unified retry orchestrator.
packages/agent/src/orchestrate/realize/orchestrateRealizeOperationWrite.ts Adds targetEndpoints filtering to focus rewrites on failed operations.
packages/agent/src/orchestrate/realize/orchestrateRealizeOperationCorrectOverall.ts Updates operation overall-correction to return standardized per-function results.
packages/agent/src/orchestrate/realize/orchestrateRealizeOperation.ts Switches operation realization to the unified retry orchestrator and uses selective endpoint retry.
packages/agent/src/orchestrate/realize/orchestrateRealizeCollectorCorrectOverall.ts Updates collector overall-correction to return standardized per-function results.
packages/agent/src/orchestrate/realize/orchestrateRealizeCollector.ts Switches collector realization to the unified retry orchestrator.
packages/agent/src/orchestrate/realize/correct/orchestrateRealizeCorrectWithRetry.ts Adds the new shared 1-retry orchestration utility.
packages/agent/src/orchestrate/realize/correct/orchestrateRealizeCorrectOverall.ts Refactors overall-correction to produce success/failure results per function.
packages/agent/prompts/REALIZE_TRANSFORMER_WRITE.md Adds guidance for null-guarding nullable Prisma relations.
packages/agent/prompts/REALIZE_TRANSFORMER_CORRECT.md Adds correction guidance/checklist for nullable relation null-guards.
packages/agent/prompts/REALIZE_OPERATION_WRITE.md Adds guidance on column-name verification and non-null DB defaults for nullable DTO fields.
packages/agent/prompts/REALIZE_OPERATION_CORRECT.md Adds correction guidance/checklist for nullable relation null-guards and non-null DB defaults.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

const retryResults: IAutoBeRealizeFunctionResult<Func>[] = await process(
await props.rewrite(failures),
);
return [...success, ...retryResults.map((r) => r.function)];

Copilot AI Apr 7, 2026

Copy link

Choose a reason for hiding this comment

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

The retry path appends all retry results (retryResults.map(r => r.function)) without filtering on r.success. This means functions that still failed after retry are returned as if they succeeded, contradicting the intended “return only successful results” behavior and potentially propagating uncompilable output. Filter retryResults to only successful entries (and consider merging with the same success/failure filtering used for the first attempt).

Suggested change
return [...success, ...retryResults.map((r) => r.function)];
return [
...success,
...retryResults
.filter((r) => r.success === true)
.map((r) => r.function),
];

Copilot uses AI. Check for mistakes.
return await correct(ctx, props, life);
}
return props.functions;
return props.functions.map((f) => ({ success: true, function: f }));

Copilot AI Apr 7, 2026

Copy link

Choose a reason for hiding this comment

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

predicate treats any non-"failure" compile result as success and marks every function with success: true. That includes result.type === "exception", which isn’t a successful validation and will be reported as success in the new result type. Consider mapping exception to success: false (or extending the result model to distinguish retryable/non-retryable failures) so callers can accurately report outcomes.

Suggested change
return props.functions.map((f) => ({ success: true, function: f }));
if (props.event.result.type === "success")
return props.functions.map((f) => ({ success: true, function: f }));
ctx.dispatch(props.event);
return props.functions.map((f) => ({ success: false, function: f }));

Copilot uses AI. Check for mistakes.
sunrabbit123 pushed a commit that referenced this pull request Apr 9, 2026
* feat(agent): 1 retry change for realize functions.

* fix format

* fix logics

* fix prompts

* fix title

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

Labels

enhancement New feature or request

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants