Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simply retry strategy for minor errors #3380

Merged
merged 9 commits into from
Sep 25, 2024
Merged

Simply retry strategy for minor errors #3380

merged 9 commits into from
Sep 25, 2024

Conversation

OAGr
Copy link
Contributor

@OAGr OAGr commented Sep 23, 2024

This closes: #3375

Also, this does minor visual updates

Copy link

vercel bot commented Sep 23, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
quri-hub ✅ Ready (Inspect) Visit Preview Sep 25, 2024 0:46am
3 Skipped Deployments
Name Status Preview Updated (UTC)
quri-ui ⬜️ Ignored (Inspect) Visit Preview Sep 25, 2024 0:46am
squiggle-components ⬜️ Ignored (Inspect) Visit Preview Sep 25, 2024 0:46am
squiggle-website ⬜️ Ignored (Inspect) Visit Preview Sep 25, 2024 0:46am

Copy link

changeset-bot bot commented Sep 23, 2024

⚠️ No Changeset found

Latest commit: 7000718

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@OAGr OAGr changed the title If one step fails, try repeating the previous step Simply retry strategy for minor errors Sep 24, 2024
packages/ai/src/workflows/SquiggleWorkflow.ts Outdated Show resolved Hide resolved
packages/ai/src/workflows/SquiggleWorkflow.ts Show resolved Hide resolved
packages/ai/src/workflows/Workflow.ts Show resolved Hide resolved
packages/ai/src/workflows/Workflow.ts Outdated Show resolved Hide resolved
packages/ai/src/workflows/Workflow.ts Show resolved Hide resolved
packages/ai/src/steps/fixCodeUntilItRunsStep.ts Outdated Show resolved Hide resolved
packages/ai/src/LLMStep.ts Outdated Show resolved Hide resolved
packages/ai/src/LLMStep.ts Outdated Show resolved Hide resolved
this.state = {
kind: "FAILED",
durationMs: this.calculateDuration(),
error,
errorType,
message,
Copy link
Collaborator

Choose a reason for hiding this comment

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

There's some awkwardness here that makes me want to suggest exceptions as a failure mechanism.

I remember you don't like exceptions, so I'll explain my observations first.

  1. You log the error here (reasonable), but then sometimes you log it again, e.g. in FixCodeUntilItRuns:
        context.fail("MINOR", newCode.value);
        context.log({
          type: "codeRunError",
          error: newCode.value,
        });

This will lead to duplicate error log entries.

Because you needed to type it as codeRunError... ok, one way around it is to pass the error to fail(), like, fail(errorType: ErrorType, message: Extract<LogEntry, { type: "error" | "codeRunError" }>), and then pass that. Fixable.

  1. But then there's also the awkwardness that the step code can call fail() and then continue to do things. Which would be mostly ignored: the step is already failed, there should be nothing to do.

This also interferes with LLMStep.run(): you had to explicitly cast this.state as CodeState there, etc.

So, how about we just use throw MinorStepError(message) as the main way to fail? Then run() becomes more natural, if we catch an error then we minor-fail and either log the message or log String(error) if it's not a minor error. And we complete() otherwise.

One reason why I like this is because we already support exceptions; steps can throw, and we don't ask step implementations to carefully try/catch their code. So they might as well throw more meaningful errors.

In other words, fail("MINOR", "message") function is unnecessary, it's identical to throw new Error("message").

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea, will experiment here.

@OAGr OAGr merged commit 5369c23 into main Sep 25, 2024
6 checks passed
@OAGr OAGr deleted the ai-fixes branch September 25, 2024 00:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Squiggle AI fails on "Seach text not found" errors
2 participants