Skip to content

feat(agent): Lume decide client for Addita, run log, and BM25 few-shot SQL examples - #88

Draft
kordless wants to merge 2 commits into
feat/hertz-otlpfrom
feat/decide-client
Draft

kordless wants to merge 2 commits into
feat/hertz-otlpfrom
feat/decide-client

Conversation

@kordless

@kordless kordless commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Implements the Lume decide client for Addita / Ollaya (POST {decide_url}/api/decide), per-store run logging (<store>/agent_runs/YYYY-MM-DD.jsonl), and BM25 few-shot SQL example injection for lume agent and lume chat.

Changes

  • src/decide.rs:
    • Opt-in only: Judging runs only when --decide-url <URL>, LUME_DECIDE_URL, or --decide (use ~/.addita/serve.json discovery) is given. The presence of ~/.addita/serve.json alone never enables judging.
    • Discovery safety: When --decide reads ~/.addita/serve.json (LUME_ADDITA_DISCOVERY_FILE), Lume accepts only loopback, host.docker.internal, or LAN URLs from the file (refusing any other URL with a clear error) and sends the file's token_file bearer only to that validated URL.
    • Probes GET {decide_url}/health or GET {decide_url}/api/version and includes "addita": {"ref": "lume-run-<uuid>"} when service == "addita" (omitted for plain Ollaya).
    • Sends a single non-streaming POST {decide_url}/api/decide (30s default timeout via --decide-timeout / LUME_DECIDE_TIMEOUT, no retries) with bounded state (<= 20 rows, <= 16 KB, rows_truncated, sql, sql_all, error, answer) and either inline questions matching presets/lume.sql_judge.json or "preset": "lume.sql_judge" (--decide-preset).
    • Records routing_model, student noul scores, student_ms, teacher_ms, teacher_model, teacher_host, addita_id, source, teacher, error, and error_code in DecideLogBlock, and prints a one-line stderr notice (judged by cloud teacher <model>) when teacher_host is not loopback/LAN.
    • Evaluates good = true when addita.final has both rows_answer_question: true and answer_supported: true, or when both noul scores are >= --decide-threshold (0.8). Stores teacher == "pending" as judged: "pending", good: false and resolves late addita.decision.final OTLP records from the TI store's docs table on subsequent runs.
    • Writes run records to <store>/agent_runs/YYYY-MM-DD.jsonl (0700 dir, 0600 file, 30-day retention pruning) and ranks recent GOOD runs (<= 90 days, <= 2000 lines) via Lume's in-memory BM25 index with coord_floor = 0.0 and minimum score floor EXAMPLES_MIN_BM25_SCORE = 1.35 (no fallback when there is no lexical overlap or only a weak one-word match) to inject up to 3 distinct SQL examples into the system prompt.
  • src/chat_sql.rs & src/main.rs:
    • Wires --decide, --decide-url, --decide-model, --decide-token-file, --decide-threshold, --decide-preset, --decide-timeout, --no-decide, --no-agent-log, and --no-examples into lume agent and lume chat.
  • tests/decide.rs:
    • Unit and integration tests against real captured Addita main (fb1d519) + Ollaya 0.7.2 (laya:en) + Ollama (qwen3.5:4b) responses (no fake/mock HTTP servers).
  • docs/ADDITA.md & CHANGELOG.md:
    • Documents CLI flags, environment variables, JSONL schema, and example injection behavior.

Real End-to-End Verification (Addita fb1d519 + Ollaya 0.7.2 laya:en + Ollama qwen3.5:4b)

  • Run 1: Answered 89°F and logged judged: true, good: true (addita_id: "4cff966e-6e96-42ae-a87e-217c8b92736b", routing_model: "laya:en", student_ms: 7265, teacher_ms: 13350, teacher_model: "qwen3.5:4b", teacher_host: "host.docker.internal:11434"). Notably, in Run 1 the student noul scored 0.4535 / 0.5208 (unsure, below 0.8), so Addita escalated to the local teacher (qwen3.5:4b), which answered true / true and produced final = good (source: "teacher")—direct evidence that teacher escalation rescues valid SQL runs where the student alone is uncertain.
  • Run 2 (-v): Injected Run 1's SQL under Past questions on this store answered with working SQL (examples, adapt; don't copy blindly):, answered 89°F in one query, and logged judged: true, good: true (addita_id: "84bc3f6c-a02c-429c-9d58-09c53f68d631", student_ms: 105, teacher_ms: 12991).

@kordless

Copy link
Copy Markdown
Contributor Author

Lead review: approved at 4ef6f56. Judging is opt-in only (--decide-url / LUME_DECIDE_URL / --decide); the discovery file alone never enables it. Discovery accepts only loopback/LAN URLs, and its token goes only to that URL. Unrelated examples are never injected (no-overlap fallback removed; BM25 floor 1.35). CI 16/16 green via throwaway PR #89 (closed). Tested end to end against real Addita fb1d519 + Ollaya + qwen3.5:4b. Stays draft; retarget to main after #87 merges.

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