feat(agents): hypothesis retry-with-error-feedback (max 1 retry)
HypothesisAgent.propose ora riprova una volta in caso di parse o validation error: il prompt user del retry include l'output precedente (troncato a 800 char) e il messaggio di errore, così l'LLM può auto-correggersi. Configurabile via max_retries (default 1). Cambia il modello dati di HypothesisProposal: completion (singolare) diventa completions: list[CompletionResult] con n_attempts. L'orchestrator itera su completions per registrare il costo di ogni chiamata LLM, incluse le retry. Phase 1 v4 mostrava 64% di parse failure recuperabili: il retry punta a tagliare quel tasso senza inflazionare i token oltre 2x worst-case. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -99,21 +99,23 @@ def run_phase1(
|
||||
continue # elite gia' valutata in generazione precedente
|
||||
repo.save_genome(run_id=run_id, generation_idx=gen, genome=genome)
|
||||
proposal = hypothesis_agent.propose(genome, market)
|
||||
cost_record = cost_tracker.record(
|
||||
input_tokens=proposal.completion.input_tokens,
|
||||
output_tokens=proposal.completion.output_tokens,
|
||||
tier=proposal.completion.tier,
|
||||
run_id=run_id,
|
||||
agent_id=genome.id,
|
||||
)
|
||||
repo.save_cost_record(
|
||||
run_id=run_id,
|
||||
agent_id=genome.id,
|
||||
tier=cost_record.tier.value,
|
||||
input_tokens=cost_record.input_tokens,
|
||||
output_tokens=cost_record.output_tokens,
|
||||
cost_usd=cost_record.cost_usd,
|
||||
)
|
||||
# Registra costo per OGNI completion (incluse retry).
|
||||
for completion in proposal.completions:
|
||||
cost_record = cost_tracker.record(
|
||||
input_tokens=completion.input_tokens,
|
||||
output_tokens=completion.output_tokens,
|
||||
tier=completion.tier,
|
||||
run_id=run_id,
|
||||
agent_id=genome.id,
|
||||
)
|
||||
repo.save_cost_record(
|
||||
run_id=run_id,
|
||||
agent_id=genome.id,
|
||||
tier=cost_record.tier.value,
|
||||
input_tokens=cost_record.input_tokens,
|
||||
output_tokens=cost_record.output_tokens,
|
||||
cost_usd=cost_record.cost_usd,
|
||||
)
|
||||
|
||||
if proposal.strategy is None:
|
||||
repo.save_evaluation(
|
||||
|
||||
Reference in New Issue
Block a user