-
Notifications
You must be signed in to change notification settings - Fork 8
fix(cli,core): handle adapter/config errors and unify missing policy handling (#57) #91
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -78,18 +78,17 @@ def run(self) -> CampaignResult: | |
| cfg = self.config | ||
| started = time.monotonic() | ||
| all_scored: list[ScoredCandidate] = [] | ||
| self._emit( | ||
| EventType.CAMPAIGN_STARTED, | ||
| { | ||
| "population_size": cfg.population_size, | ||
| "max_generations": cfg.max_generations, | ||
| "elite_count": cfg.elite_count, | ||
| }, | ||
| ) | ||
|
|
||
| generations_done = 0 | ||
| try: | ||
| self._emit( | ||
| EventType.CAMPAIGN_STARTED, | ||
| { | ||
| "population_size": cfg.population_size, | ||
| "max_generations": cfg.max_generations, | ||
| "elite_count": cfg.elite_count, | ||
| }, | ||
| ) | ||
| population = self._initial_population() | ||
| generations_done = 0 | ||
|
|
||
| for gen in range(cfg.max_generations): | ||
| if self._budget_exceeded(started): | ||
|
|
@@ -174,14 +173,37 @@ def run(self) -> CampaignResult: | |
| ) | ||
|
|
||
| except ToolsNotObservableError as exc: | ||
| self._emit(EventType.CAMPAIGN_ERROR, {"error": str(exc)}) | ||
| try: | ||
| self._emit(EventType.CAMPAIGN_ERROR, {"error": str(exc)}) | ||
| except Exception: # noqa: BLE001, S110 | ||
| pass | ||
| best = max(all_scored, key=lambda c: c.fitness) if all_scored else None | ||
| violated = any(c.violated for c in all_scored) | ||
| gens = generations_done if generations_done > 0 else (1 if all_scored else 0) | ||
| return CampaignResult( | ||
| status="error", | ||
| reason="tools_not_observable", | ||
| generations_completed=0, | ||
| generations_completed=gens, | ||
| candidates=all_scored, | ||
| best=None, | ||
| violated=False, | ||
| best=best, | ||
| violated=violated, | ||
| events_emitted=self._events_emitted, | ||
| ) | ||
| except Exception as exc: # noqa: BLE001 | ||
| try: | ||
| self._emit(EventType.CAMPAIGN_ERROR, {"error": str(exc)}) | ||
| except Exception: # noqa: BLE001, S110 | ||
| pass | ||
| best = max(all_scored, key=lambda c: c.fitness) if all_scored else None | ||
| violated = any(c.violated for c in all_scored) | ||
| gens = generations_done if generations_done > 0 else (1 if all_scored else 0) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Blocking: I reproduced it with an Fix: |
||
| return CampaignResult( | ||
| status="error", | ||
| reason=str(exc) or type(exc).__name__, | ||
| generations_completed=gens, | ||
| candidates=all_scored, | ||
| best=best, | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Preserving Reproduced with That reintroduces the traceback this PR is supposed to kill (default |
||
| violated=violated, | ||
| events_emitted=self._events_emitted, | ||
| ) | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Non-blocking: this is what makes
mutiny init && mutiny runexit 2 instead of falling into Corestatus=erroron lazyagent_refload. Fine for Adapter #1.If you touch this file for the minimize guard, a one-line comment that this is an eager resolve for
OpenAIAgentsAdapter(not part ofTargetAdapter) would help the next reader. Do not expand into #27 AGENT_REF copy.