Skip to content

fix: mutable defaults + clean error handling in hypothesis refiner#88

Closed
DavidJBianco wants to merge 2 commits into
batch-c-logging-opt-infrom
batch-d-refiner-fixes
Closed

fix: mutable defaults + clean error handling in hypothesis refiner#88
DavidJBianco wants to merge 2 commits into
batch-c-logging-opt-infrom
batch-d-refiner-fixes

Conversation

@DavidJBianco

Copy link
Copy Markdown
Collaborator

Summary

Two fixes to hypothesis_assistant/hypothesis_refiner_cli.py and four other assistant entrypoints, applied in dependency order:

Commit 1 — Mutable default previous_run (supersedes #83)

Replaces previous_run: list = list() with previous_run: Optional[list] = None across all five assistant entrypoints:

  • able_assistant/__init__.py
  • data_assistant/__init__.py
  • hypothesis_assistant/hypothesis_refiner_cli.py
  • planning_assistant/__init__.py
  • research_assistant/__init__.py

All call sites already guard with if previous_run: so the change is behavior-preserving.

Commit 2 — Remove double-wrap in refiner(), add clean CLI error boundary (supersedes #77)

Root cause: refiner() had an inner try/except that (a) printed to stdout (garbling parseable CLI output), (b) re-raised as a generic Exception, discarding the original type and making narrow handling impossible for any caller.

Fix:

  • Remove the inner try/except from refiner() entirely. Exceptions now propagate with their native type and full traceback intact.
  • Add a single try/except Exception at the CLI boundary in main() around asyncio.run(refiner(...)). On failure: prints a concise message to stderr, shows the full traceback with --verbose, exits with code 1.

This is the correct layer for this handler — a CLI's job is to not dump tracebacks at users by default, not to discriminate between autogen/provider exception types.

Closes #77 and #83 (both superseded).

Test plan

  • python3 -m compileall peak_assistant — passes
  • Run the refiner CLI with a bad LLM config — should print one stderr line and exit 1 (no traceback)
  • Same with --verbose — should print full traceback
  • Normal refinement run is unchanged

🤖 Generated with Claude Code

DavidJBianco and others added 2 commits April 23, 2026 09:52
The inner try/except in refiner() was printing to stdout (garbling
parseable output) and re-raising as a generic Exception, discarding
the original type. Remove it so exceptions propagate with their native
type and traceback intact.

Add a single exception handler at the CLI boundary in main() that
prints a concise message to stderr, shows the full traceback with
--verbose, and exits with code 1.

Supersedes PR #77.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@DavidJBianco

Copy link
Copy Markdown
Collaborator Author

Merged into dev via fast-forward (batch-d-refiner-fixes chain).

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant