shareAI-lab/learn-claude-code · error · SystemExit
error: {error}
Error message
error: {error} What it means
This is the top-level CLI exit wrapper (s17_goal_loop/code.py:882): asyncio.run(main(...)) raised a GoalError or ValueError, and the handler converts it into SystemExit with the message prefixed 'error: {error}', printing it to stderr and exiting non-zero. It is a reporting boundary, not an error of its own — the underlying message (e.g. 'MODEL_ID is required...') names the real problem.
Source
Thrown at s17_goal_loop/code.py:882
except (EOFError, KeyboardInterrupt):
break
if query.strip().lower() in {"q", "quit", "exit"}:
break
if not query.strip():
continue
result = await session.submit(query)
if result.text:
print(result.text)
if result.reason:
print(f"[goal] {result.status}: {result.reason}")
print()
if __name__ == "__main__":
try:
asyncio.run(main(sys.argv[1:]))
except (GoalError, ValueError) as error:
raise SystemExit(f"error: {error}") from error
View on GitHub (pinned to 985456f4ad)
Solutions
- Read the text after 'error: ' — it is the specific validation message from the deeper layer; fix that cause (see the matching error in this index)
- Run with missing-argument validation before main() so usage errors print a usage message instead
- For scripted use, call main() via try/except SystemExit to capture the message programmatically
Example fix
# before $ python -m s17_goal_loop.code "" error: goal condition cannot be empty # after $ python -m s17_goal_loop.code "tests pass with pytest"
Defensive patterns
Strategy: try-catch
Validate before calling
args = sys.argv[1:]
if not args or not args[0].strip():
raise SystemExit("usage: python -m s17_goal_loop.code <goal condition>")
if not os.getenv("MODEL_ID") and not Path(".env").exists():
raise SystemExit("configure MODEL_ID in .env before running") Try / catch
try:
asyncio.run(main(sys.argv[1:]))
except SystemExit as exit_error:
message = str(exit_error)
if message.startswith("error: "):
handle_root_cause(message[len("error: "):]) # route to the real fix
else:
raise Prevention
- Treat 'error: ...' as a wrapper; always read the suffix, which names the true validation failure
- Validate CLI args and env config before main() so setup failures print usage, not raw errors
- When embedding the CLI in scripts, catch SystemExit to capture the message for logging
When it happens
Trigger: Running the module as a script (__main__) with any invalid input: empty goal condition, block_cap/max_turns < 1, missing MODEL_ID, missing dependencies, unknown tool, or a path-escape during a live run. Any GoalError/ValueError raised anywhere under main() lands here.
Common situations: First-run setup failures (no .env, deps not installed); bad CLI arguments (empty goal text); runtime tool-misuse errors during an agent session; anything the deeper validation layers already rejected.
Related errors
- goal evaluator returned invalid JSON
- goal evaluator must return a JSON object
- goal evaluator response requires boolean 'ok'
- goal evaluator response requires non-empty 'reason'
- goal evaluator 'impossible' must be boolean
AI-assisted analysis of shareAI-lab/learn-claude-code@985456f4ad (2026-08-14).
Data as JSON: /api/errors/9f17ba9387c83801.
Report an issue: GitHub.