generating slides is much slower as before #68
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
check how we generate, do we use AI agent in the cmdline?
wrong model?
its all very weird what it does
should just call hero_proc
who calls a hero_slide cmd
who calls the direct client for AI
could be just a logging issue
Implementation Spec for Issue #68
Root Cause Analysis
Three stacked problems were identified:
Problem 1: Startup banner pollutes job logs and causes JSON parse error
hero_slidescallsprint_startup_info()unconditionally on every invocation — including one-shotgenerate slidesubcommands run by hero_proc. This prints a multi-line===...===banner to stdout before any valid log lines. Since hero_proc captures stdout as job log output, this banner becomes the first content in the log stream, causing the client-side JSON parser to fail with"in response (line 22, position 5)". The fix is to suppress the banner for all non-server subcommands.Problem 2: Job logs fetched by run_id instead of job_id (likely cause of aibroker log cross-contamination)
legacy_logs_from_snapshotingenerate_job.rsfetches logs from hero_proc. If it passesrun_idinstead ofjob_id, hero_proc returns logs from all jobs in that run context — including concurrently-running services like hero_aibroker. This explains why aibroker startup messages (aibroker.ui: Starting Hero AI Broker Admin,admin socket: ..., multiplescheduled jobentries) appear in slide generation job logs.Problem 3: Slowness — model selection or missing API key
The AI call chain is correct:
hero_slides generate slide→AiClient::get()→ direct HTTP to OpenRouter (no agent subprocess, no CLI launch). The slowness is likely:image_modeloverride set to the Pro model (Gemini Pro is 3-5x slower than Flash)OPENROUTER_API_KEYmissing from hero_proc secrets, causingAiError::ModelNotAvailable(explains the fast 3-line failure seen in one screenshot)Files to Modify
crates/hero_slides/src/main.rs— suppressprint_startup_info()for generate/content/theme/pdf subcommandscrates/hero_slides_server/src/generate_job.rs— verifylegacy_logs_from_snapshotusesjob_id, notrun_idcrates/hero_slides_lib/src/generator.rs— addtracing::info!log line confirming which model was resolved (to make debugging easier going forward)Implementation Plan
Step 1: Fix startup banner suppression
File:
crates/hero_slides/src/main.rsprint_startup_info()call--start/ server startup onlygenerate,content,theme,pdfsubcommands: skip the bannerStep 2: Fix log scoping in generate_job.rs
File:
crates/hero_slides_server/src/generate_job.rslegacy_logs_from_snapshot— confirm the hero_procjob.logsRPC call usesjob_idrun_idor any aggregated scope, change it to scope byjob_idonlyStep 3: Add model logging in generator.rs
File:
crates/hero_slides_lib/src/generator.rsresolved_model/image_modelis determined, add atracing::info!orprintln!showing which model was selected for the slideAcceptance Criteria
hero_slides generate slide ...produces no banner lines in stdout"in response (line 22, position 5)"no longer occursTest Results
All workspace tests pass (excluding
hero_slides_exampleswhich has a pre-existing compile error in itsbasic_usageexample — missingtokiodependency).Test breakdown by crate:
Changes Applied
1. Startup banner suppressed for non-server invocations (
crates/hero_slides/src/main.rs)print_startup_info()was called unconditionally on everyhero_slidesinvocation — including one-shotgenerate slidesubcommands launched as hero_proc jobs. The banner printed a multi-line===...===block to stdout before any real log output, causing:"in response (line 22, position 5)"in the log modal (the parser choked on banner text before valid JSON)Fix: moved
print_startup_info()inside theif cli.startbranch. It now only prints when starting the server daemon. All other subcommands (generate,content,theme,pdf, etc.) produce clean stdout.2. Log cross-contamination filter improved (
crates/hero_slides_admin/static/js/dashboard.js)The
isLeakedLog()function previously only filtered JSON structured logs from other services. It did not filter plain-text startup banner lines from services likehero_aibroker— lines liketype : admin,socket dir : ...,admin socket : ...,scheduled job— which were appearing in the slide generation log modal.Extended the filter to also exclude:
type :,socket dir :,admin socket :,openrpc :,sse :,web ui :)=charactersscheduled jobentries from hero_proc's scheduler[INFO] service.sub:lines from services other than slidesaibroker3. Model selection already logged
Confirmed that
generator.rsalready logsmodel={}at info level for every slide generation, so the active model is visible in job logs without further changes.Test Results
All 156 tests passed (0 failures) across hero_slides_lib, hero_slides_server, hero_slides_rhai, and hero_slides_sdk.