Skip to content

Fail AMR insufficient-balance runs before session startup #5094

Description

@AmyShang-alt

Problem

When an AMR account has insufficient balance, Open Design still spends close to 10 seconds before surfacing the recharge card.

This is separate from PR #5053. PR #5053 correctly classifies AMR/Vela structured insufficient-balance errors as AMR_INSUFFICIENT_BALANCE, but the user-visible failure still arrives late because the error is only returned after AMR/Vela session creation and event-stream startup.

Evidence

Validated locally in PR #5053 Electron runtime:

  • Worktree: /Users/mac/open-design/pr-5053-electron
  • PR head: f35299f0b20b0070d13b04bbf9e038ac07a741a2
  • Namespace: pr5053
  • Run/trace id: cf0af90f-326d-47f8-a35c-f587d590c0ca
  • Model: deepseek-v4-flash
  • UI displayed: 已完成 9.9s

Run event timeline:

  • 03:33:15.454 run start
  • 03:33:21.217 AMR opencode session created, about 5.8s after start
  • 03:33:24.240 Open Design emitted AMR_INSUFFICIENT_BALANCE, about 8.8s after start
  • 03:33:24.899 run ended failed, about 9.4s after start

AMR runtime log showed the balance failure only at event-stream phase:

opencode_event_stream_failure ... phase=event_stream ... status.message="[code=insufficient_balance] insufficient wallet balance"

Expected

If Open Design already knows the AMR account balance is insufficient, the run should fail before starting the expensive AMR/opencode session path, ideally within a short preflight step.

The UI should still show the existing AMR_INSUFFICIENT_BALANCE recharge card, but without spending close to 10 seconds.

Possible fixes

  • Add an Open Design-side AMR wallet/balance preflight before starting AMR runs.
  • Or have Vela/ACP return structured insufficient-balance details during session initialization instead of waiting until event stream.

Acceptance

  • With an insufficient-balance AMR account, starting a run surfaces the recharge card quickly rather than after session/event-stream startup.
  • The error code remains AMR_INSUFFICIENT_BALANCE.
  • The recovery card still includes the recharge action URL.
  • Auth-required and unrelated model/service errors are not misclassified as insufficient balance.
Image

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions