Skip to content

glacez-soa-agent

Lane: backend · Repo: glacez/glacez-soa-agent · Editing rules: Glacez/SOAs/glacez-soa-agent/AGENTS.md

The LLM service: renders a task prompt, calls one OpenAI-compatible endpoint, persists the report with its generation metadata.

Responsibility

Report family Scope Endpoints
daily positions per user /users/{username}/reports/daily-positions[/latest\|/{reportId}]
daily portfolio per user /users/{username}/reports/daily-portfolio[/latest\|/{reportId}]
news digest global /agent-news-reports[/{reportDate}]
BTC trend global /agent-btc-trend-reports[/{reportDate}]
profiles per user /agent-profiles[/{profileId}\|/{profileId}/persona]

It does not own: market data (findata), positions (portfolio), the user-facing API (webservice, which also reads these reports).

AI layer

Prompt context → one renderer per task type → request factory (model + max tokens) → OpenAiClient (plain RestClient against OpenRouter /chat/completions) → response mapped onto the report draft. Prompt wording lives in classpath YAML personas and skills, not in Java.

Two constraints that are decisions, not defaults:

  • Reasoning is disabled for every job. On a long prompt the thinking tokens can consume the whole output budget and return no content at all. A report that comes back empty is a budget symptom before it is a prompt bug.
  • One model for every task and both subscription tiers (glacez.ai.openrouter.model). No per-task map, no free/pro split — add one only if a tier actually needs a different model.

Quotas

Monthly LLM calls per user are enforced for user-scoped jobs only: 100 on the free tier, 1000 on pro. Global reports (news digest, BTC trend) are not user-scoped and do not consume a quota.

Data it writes

The four report families, AgentProfile, InvestmentProfile, and it increments the user's usage counter. Every report document carries status, provider, model, promptVersion, token counts, latencyMs, finishReason, errorMessage, jobId — a failed generation is diagnosable from the document alone. An empty completion or one the provider cut at max_tokens is stored as FAILED, never as COMPLETED with null content.

Reads Position and market series from portfolio and findata over Feign.

Jobs and ordering

Bodyless POST /jobs/reports/{daily-positions,daily-portfolio,news-digest,btc-trend} and /jobs/investment-profile/{username}/summarize. Report jobs always use today in UTC — there is no backfill parameter.

Ordering matters and is owned by glacez-infra-cron: news digest → BTC trend → daily positions, because a daily report embeds the latest of the other two. Regenerate the futures first when testing by hand, or the daily report embeds stale input.

Job ctlq prod
news digest Sunday 10:00 daily 06:00
BTC trend Sunday 11:00 daily 07:00
daily positions Sunday 12:00 daily 08:00
daily portfolio Sunday 13:00 daily 13:00

Cost

Every report is a paid API call and a full model session. A runaway cadence is a cost incident, not a performance issue — check the cronfile before the code.