Skip to content

Fix runtime embedder injection for offline tests - #31

Open
taditya1997 wants to merge 1 commit into
theschoolofai:mainfrom
taditya1997:assignment16-runtime-embedder-injection
Open

taditya1997 wants to merge 1 commit into
theschoolofai:mainfrom
taditya1997:assignment16-runtime-embedder-injection

Conversation

@taditya1997

Copy link
Copy Markdown

What breaks

AgentRuntime() always constructs OllamaNomicEmbedder, so runtime-level tests that only need graph/capability wiring can still make a live request to localhost:11434 while writing the inbound memory record. On a clean machine without Ollama running, tests/test_capability_contracts.py::test_every_registered_capability_has_a_worker_and_every_worker_is_registered fails before it reaches the patched executor probe.

Proof before the fix

From a fresh checkout with no Ollama service on localhost:11434:

FAILED tests/test_capability_contracts.py::test_every_registered_capability_has_a_worker_and_every_worker_is_registered
urllib.error.URLError: <urlopen error [Errno 61] Connection refused>

I also added test_agent_runtime_accepts_an_injected_memory_embedder, which initially failed with:

TypeError: AgentRuntime.__init__() got an unexpected keyword argument 'memory_embedder'

Fix

Add an explicit memory_embedder constructor argument to AgentRuntime, defaulting to the existing OllamaNomicEmbedder() for production behavior. The capability-contract probe now uses the public injection seam with DeterministicEmbedder, so it remains offline and verifies the intended worker/registry contract.

Verification after the fix

uv run ruff check .
All checks passed!

uv run pytest -q
356 passed, 1 warning in 38.58s

No .env, credentials, tokens, real messages, or personal data are included.

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