Skip to content

feat(bus): claim tasks by reference and name the task on every call (lake#871) - #39

Open
homer6 wants to merge 1 commit into
devfrom
feat/by-reference-claims
Open

homer6 wants to merge 1 commit into
devfrom
feat/by-reference-claims

Conversation

@homer6

@homer6 homer6 commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

What: This agent now claims each bus task with credentials: by_reference, so Lake never hands it the task's credential. Every call the turn makes to Lake carries the agent's own bus credential and the header X-Lake-Agent-Task: <task id>.
Why: The agents' half of oramasearch/lake#871: a library agent is one process serving every tenant, so a task credential in its memory could be taken elsewhere. Lake's half is oramasearch/lake#1304.
How: lake_bus.py asks for by_reference and, when Lake answers that way, fills the turn's credential fields with the bus credential and adds lake_headers naming the task. The Lake client and the model gateway client send that header. A Lake without lake#1304 refuses the new field before claiming anything; the claim is then asked again without it and the body's own credential is used, as today.

Tests not run: per Steve, 2026-11-14, tests run at review and release time. Tests were written (below).

The same change is in every library agent, from the shared lake_bus.py (reference: oramasearch/agent-ask-orama#65).

Changes

  • src/agent_experiments/lake_bus.py: claim asks credentials: by_reference and, on invalid_input naming credentials (a Lake from before lake#871), asks again without it. Any other refusal is not retried. task_credentials fills lake_token / zetta_token with the bus credential and sets lake_headers only when the claim answer says credentials: by_reference; otherwise the body is used as it came. task_headers(body) returns only X-Lake-Agent-Task. Bus calls (receive, claim, publish) never send the header, since Lake would then answer them as the task.
  • src/agent_experiments/model.py: gateway_client(..., headers=) sends the header on every model call through Lake's gateway.
  • src/agent_experiments/agent.py: Turn.lake_headers, sent by the turn's Lake client on every capability read and write.
  • src/agent_experiments/service.py: run_turn fills Turn.lake_headers from lake_bus.task_headers(body) and passes it to the gateway client.
  • Docs: README.md, docs/operations/service.md (No task credential reaches this process).

Tests

  • New tests/test_by_reference.py: the claim asks by_reference and the turn holds the bus credential and the task header; a Lake that refuses the field is asked again and the body's credential is used with no header; another refusal is not retried; task_headers keeps only the task header; the turn's model call and its Lake reads and writes send the bus credential and X-Lake-Agent-Task; an in-body turn sends no task header.
  • tests/test_service.py, tests/test_turn_destinations.py: the patched gateway_client accepts the new headers keyword. tests/test_lake_bus.py: the recording bus has a token, which run_task now reads.

Rolling

No roll order. This works against today's Lake (in-body, by the fallback) and against Lake with oramasearch/lake#1304 (by reference). oramasearch/lake#871 stays open: Lake removes the in-body mode once every library agent claims by reference.

Likely conflicts with open pull requests

…lake#871)

Each claim asks Lake for credentials: by_reference, so no task credential
reaches this shared process. The turn calls Lake (capability reads and
writes, and the model gateway) with the agent's bus credential and the
header X-Lake-Agent-Task: <task id>. A Lake from before lake#871 refuses
the field before claiming; the claim is then asked again without it and
the body's credential is used as before.
@homer6

homer6 commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author

Deferred on Steve's review (2026-11-16), not in this release: it is the by-reference-claims feature (lake#871), which needs the matching Lake change and was judged not low risk.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

on-hold Deferred; not in the current release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant