Skip to content

Add OpenAI-compatible BrainDB agent support#3

Closed
WarGloom wants to merge 5 commits into
dimknaf:mainfrom
WarGloom:setup/local-ollama-agent
Closed

Add OpenAI-compatible BrainDB agent support#3
WarGloom wants to merge 5 commits into
dimknaf:mainfrom
WarGloom:setup/local-ollama-agent

Conversation

@WarGloom
Copy link
Copy Markdown
Contributor

@WarGloom WarGloom commented May 3, 2026

Summary

  • Add local stack management, safe Docker build context, and compose-managed Postgres for easier development.
  • Add Codex and generic OpenAI-compatible agent profiles, including copilot-api/Ollama configuration and docs.
  • Harden agent/tool behavior with SQL activity logging, UUID validation, simple save fast paths, and structured max-turn responses.

Validation

  • podman exec -e BRAINDB_TEST_URL=http://localhost:8100 braindb_api python -m pytest tests/test_config_profiles.py tests/test_agent_tools_validation.py tests/test_memory_sql.py tests/test_agent_fast_path.py tests/test_agent.py::test_agent_query_smoke -q
  • Result: 18 passed

@WarGloom WarGloom force-pushed the setup/local-ollama-agent branch from b88cf32 to 9e240f6 Compare May 10, 2026 20:45
@dimknaf
Copy link
Copy Markdown
Owner

dimknaf commented May 25, 2026

Hi @WarGloom — thanks for the work and the time spent on this. Going to be candid: this PR bundles five different concerns, and after the v0.2.0 merge (#6) plus PR #5 landed it now sits on top of 7 conflicts. After reading through it carefully I think the cleanest path is to close this PR and explain piece by piece, so you can decide what (if anything) is worth your time to come back with.

Worth opening as a small new PR — we'd very likely accept:

  • OpenAI-compatible LLM profile (your b8f2bf8 commit). I verified the implementation routes through LitellmModel and doesn't introduce a raw openai SDK path — that matters to us: one provider abstraction, no parallel paths, ever. A focused new PR that just adds an openai_compatible entry to _LLM_PROFILES, an AGENT_BASE_URL env passthrough in docker-compose.yml, the docs lines, and a small unit test — that we'd be happy to take. A few notes for that PR:
    • The codebase reads provider keys via os.getenv everywhere — please follow that convention rather than introducing typed Pydantic fields (openai_api_key, etc.) and a field-vs-env fallback helper. Tests can inject keys with monkeypatch.setenv (your own test_codex_profile_resolves_api_key_from_environment already does this correctly).
    • One name is enough — openai_compatible is clear; the local_ollama alias adds indirection without earning it.
    • Base it on current main (post-v0.2.0). The dict has new entries (vllm_workstation_qwen, vllm_workstation_gemma) and Settings now carries fields the wiki/maintainer/writer pipeline depends on, so a wholesale-replace would silently downgrade things.

The other pieces — being honest, they likely won't land:

  • Agent save fast-path (braindb/agent/fast_path.py, your 75be7f7). This regex-bypasses the agent for ^Save: … queries and writes the fact with keywords=[] and no relations. Architecturally we can't take this: BrainDB's value is the recall-first → relate-to-existing → write loop, and a fact saved without it sits orphaned in the graph (no tagged_with edges, no keyword entities) and won't surface from /memory/context later. If "simple saves feel ceremonial" is the pain, the right fix lives inside the agent — a prompt nudge to skip recall when the user explicitly says just save this — not a router-layer bypass.
  • In-compose Postgres + scripts/braindb-manage.sh (your 94d0a2c). BrainDB is built against an external Postgres (CLAUDE.md is explicit). A bundled Postgres service plus a 357-line bash management layer would give the project two ways to run, and we want to keep the default surface small. If you have ideas for easier first-run for new contributors, an issue (not a PR) is the right venue — likely answer would be a Compose profile that keeps external as the default — but worth discussing first.
  • Tool/SQL hardening (969a55e). There are genuine correctness wins in this commit (UUID placeholder guard, activity-log-in-new-transaction). But it's intertwined with the _save_fact_impl extraction that only exists to feed the fast-path above, and it doesn't extend to the wiki tools added in v0.2.0. We'll likely fold the bits we want into our own future work rather than ask you to untangle it.

Closing the PR now so it doesn't sit open through the release, but please don't read that as a dismissal — the OpenAI-profile commit specifically would be a welcome contribution as its own focused PR if you'd like to send one. Thanks again for engaging with the project.

@dimknaf dimknaf closed this May 25, 2026
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.

2 participants