Skip to content

tools: pydantic-ai agent sandbox driving loseit CLI via homelab Ollama#75

Open
phitoduck wants to merge 2 commits into
mainfrom
local-model
Open

tools: pydantic-ai agent sandbox driving loseit CLI via homelab Ollama#75
phitoduck wants to merge 2 commits into
mainfrom
local-model

Conversation

@phitoduck

Copy link
Copy Markdown
Owner

Summary

  • Adds tools/agent-sandbox/: single-file pydantic-ai agent (agent.py) that drives the loseit CLI via 5 tools — one per non-destructive subcommand. delete and login are deliberately omitted.
  • Control flow is handled entirely by the homelab-hosted qwen3:8b Ollama model at https://ollama.priv.mlops-club.org/v1 (Tailscale-only).
  • Docker image based on ghcr.io/astral-sh/uv:python3.12-bookworm-slim, runs as non-root, only mount is ~/.config/loseit/ read-only.
  • Per-run logging: one file at runs/run-{UTC}.log capturing the prompt, system prompt, every tool args+return, the full final message history (every model request/response with parsed tool_call args), and token usage. Mountable to the host.

End-to-end run on the goal prompt (255g asparagus/lentils/red-potato mix + 100g guacamole) lands all 4 entries correctly in the diary, verified via readback.

Snacks (2026-06-12):
  Asparagus, Spears, Cooked    85g    18.7 cal
  Beans, Lentils, Cooked       85g    98.6 cal
  Potatoes, Red, Baby, Cooked  85g    75.6 cal
  Guacamole                   100g   202.8 cal
                       Total:        395.7 cal

Notes

  • lose-it itself is unpublished, so the image installs it from git+https://github.com/phitoduck/lose-it@${LOSEIT_REF} (default main, override with --build-arg).
  • A small tool-side guardrail in log_food refuses absurd-magnitude tbsp/tsp/fl_oz logs — the small model otherwise falls back to grams ÷ g-per-tbsp math instead of re-searching for a gram-supporting food entry.

Test plan

  • Build the image: docker build -t loseit-agent tools/agent-sandbox
  • Smoke test auth: docker run --rm -v ~/.config/loseit:/home/agent/.config/loseit:ro --entrypoint /home/agent/.venv/bin/loseit loseit-agent whoami
  • Run end-to-end with a real prompt (Tailscale required) and confirm entries land via loseit diary
  • Inspect runs/run-*.log to verify all LLM + tool I/O is captured

Single-file agent (`tools/agent-sandbox/agent.py`) exposing one tool per
non-destructive loseit subcommand (search, log_food, diary, describe_food,
whoami). Control flow is driven by the homelab-hosted `qwen3:8b` Ollama
model via the new `ollama.priv.mlops-club.org` ingress.

The Docker image is built on `ghcr.io/astral-sh/uv:python3.12-bookworm-slim`,
runs as non-root, mounts only the user's loseit credentials read-only, and
persists per-run logs (LLM I/O + tool I/O + full message history) to a
host-bind directory.

Per-prompt logging makes the iteration loop legible — every model
input/output and tool input/output for one run lands in a single file.

NOT FOR MERGE — exploratory work on driving the local Ollama model end-to-end.
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