Repository navigation
Conversation
The server names a call's run on its ledger row from `X-Loom-Run-Id`, and reads a body `run_id` only where the op's input declares one. The Python SDK sent the header on the four recall reads inside a `run_scope`, and under `auto_run` on the memory, working-memory, observe and context planes except their writes. The TypeScript SDK sent it on no call. A call inside a run to an op with no `run_id` field, such as `memory.promote`, was recorded under no run, so a report built from the ledger missed it. Python: every call inside a `run_scope` carries the header. Under `auto_run` a memory-plane call still opens the run, and from then on every call on any plane carries the header. `ReferenceClient` labels every call while its run is open. The body `run_id` is sent where it was: on writes, and never on a recall read, where it filters to the run's own rows. TypeScript: `CallOptions.runId` sends the header and leaves the body as it is. `Agent.call` passes the scope's `runId` as that option, so the verbs, `Session` and `AgentTools` label their calls; the body is unchanged. A run id is the caller's own string. One with a character outside printable ASCII is not a header value and would fail the request, so it is not sent and the call goes out as before. No server change. Related: #1760 Signed-off-by: Mohammad Lareb Zafar <lareb.zafar@clickhouse.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit f0fa5b9. Configure here.
…caller passes wins under auto_run TypeScript: `AgentTools` sends `loom_code_lookup` through the client, not through `Agent.call`, so the call carried no `X-Loom-Run-Id`. The code ops it reaches (`code.symbol`, `code.search`, `code.callers`, `code.impact`) declare no `run_id`, so the server dropped the body's run and recorded the lookup under no run. The lookup passes the scope's `runId` as the call option. Python: `Transport.post_with_meta` applied the `before_post` hook's headers over the ones the caller passed in `extra_headers`. With the ambient run labelling every call, a call that named its own run in `X-Loom-Run-Id` was recorded under the ambient run. The hook's headers are applied the way a run scope's are: a header the caller passed is kept. The sender census pins `sdk/python/loom/run.py` as it is; no sender call in it changed. The agent guide in `skills/loom/` says every call in a Python run scope is labelled with the header and that the body `run_id` goes only on the listed writes. The Python SDK page says a run id outside printable ASCII is not sent as the header. The TypeScript pages say the tools take `runId` in their scope. Related: #1760 Signed-off-by: Mohammad Lareb Zafar <lareb.zafar@clickhouse.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Related: #1760
Changelog category (leave one):
Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):
A call the Python SDK makes inside a
run_scopeor underauto_run, and a TypeScript SDK call given arunId, is recorded under its run in the op ledger also when the op's input has norun_idfield, such asmemory.promote. Both SDKs send the run inX-Loom-Run-Idon every such call, and the TypeScript SDK gains the per-call optionrunId, which labels a read without filtering it.Why
The server names a call's run on its ledger row from the
X-Loom-Run-Idheader (set_ledger_runinserver/transport/http.py) and reads a bodyrun_idonly where the op's input declares one (run_id_ofinserver/observability/ledger.py). An SDK that puts the run only in the body is recorded under no run on every op that has no such field, and a report built from the ledger misses those calls.What the SDKs did, read on
main:run_scopememory.search,memory.search_trace,memory.ask,memory.listmemory.promotecarried the run in a body field the server dropsauto_runmemory.*,working_memory.*,observe.*andcontext.*call except the ten writes that carry the run in the bodyReferenceClientwith an open runrunIdto an op with norun_idfieldThe fix is the header on every call that carries a run, not a list of ops, so a new op needs no SDK change.
scope_label(wasscope_read_label) returns the header for every op inside arun_scope, and still takes the scope'srun_idoff a recall read's body, where it would filter to the run's own rows.AmbientRun.before_postopens the run on a memory-plane call as before, and from then on labels every call on any plane, the stamped writes included.ReferenceClientlabels every call while its run is open. A header the caller passes inextra_headersis kept over the ambient run's, as it is over a run scope's, so a call that names its own run inX-Loom-Run-Idis recorded under that run.CallOptions.runIdsends the header and leaves the body as it is.Agent.callpasses its scope'srunIdas that option, so the verbs,SessionandAgentToolslabel their calls; the two callsAgentToolssends through the client itself (loom_update, andloom_code_lookup, whose code ops declare norun_id) pass the option directly. A read givenrunIdonly as the call option is labelled and not filtered, which the SDK could not do before.httpxandfetchrefuse it before the request is sent, which would fail a write that works today. Such an id is not sent as a header and the call goes out as before.Scope and risk
sdk/python/loom/run.py,transport.py,reference_client.py,agent.py(a docstring);sdk/typescript/src/transport.ts,agent.ts,tools.ts. No server change, no op, field, table or setting. The agent guide inskills/loom/, whichmentor.guideserves, says what a Python run scope now labels.run_idis sent exactly where it was. A write keeps it (the row's provenance); a recall read inside a scope still carries none.run.getandrun.reliancelist reads they did not list (amemory.get_by_idor a document read inside arun_scope), and amemory.outcomemade inside arun_scopeis credited under the run, sorun.retract_creditwith that run reaches it. Underauto_runthis was already so for the memory planes.auto_run, the run'scallscount inrun.complete's metadata is unchanged: it counts the memory-plane calls.auto_run, a call that passesX-Loom-Run-Idinextra_headerskeeps that label on every op. Onmainthe ambient run's label replaced it on the memory-plane calls the ambient run labelled.tests/unit/session_content_senders.json) pinssdk/python/loom/run.pyas it is now. No sender call in that file changed: the five reviewedrun.*sites keep their keys.run_id=outside a scope to an op with no such field (Agent.call(op, run_id=...)) still names no run; the Go, Ruby, Java and .NET clients send no run header.Compatibility, rollout and rollback
X-Loom-Run-Id, which the server already reads on every op, is sent on more calls.CallOptions.runIdis new and optional. In Python,loom.run.scope_read_labelis renamedscope_labelwith no alias, andloom.run.run_headeris new; neither is exported fromloom.Tests
Failing first, on the tree before the change:
tests/unit/test_sdk_run_scope_read_label.py:test_a_call_to_an_op_with_no_run_id_field_carries_the_headerandtest_a_write_in_the_scope_carries_the_header_and_its_body_run_idfailed withassert None == 'run-1'(2 failed, 4 passed).tests/unit/test_reference_client.py::test_an_open_run_stamps_writes_and_leaves_reads_unfilteredfailed on the missing header ofmemory.set.sdk/typescript/src/client.test.ts,run label: 2 failed withexpected undefined to be 'r1', 1 passed (the call outside a run).test_a_run_id_a_header_cannot_carry_labels_nothingfailed for both ids once every call carried the header, beforerun_headerchecked the id.tests/unit/test_sdk_ambient_run.py::test_a_label_the_caller_passes_wins_over_the_ambient_runfailed withassert 'amb-1' == 'mine'.run labelinsdk/typescript/src/client.test.ts, with aloom_code_lookupcall through tools bound to arunId: failed withexpected undefined to be 'r2'.tests/unit/test_session_content_senders.py::test_shipped_automatic_senders_have_an_admission_class_or_reviewed_exceptionfailed on the pin ofsdk/python/loom/run.py, and on nothing else.On the final tree:
pytest -n 2 tests/unit/test_sdk_ambient_run.py tests/unit/test_session_content_senders.py tests/unit/test_sdk_run_scope_read_label.py tests/unit/test_sdk_run_scope.py tests/unit/test_reference_client.py tests/unit/test_sdk_agent_call.py tests/unit/test_sdk_consumer_identity.py tests/unit/test_sdk_session_protection.py tests/unit/test_sdk_hardening.py tests/unit/test_sdk_retry_logging.py tests/unit/test_sdk_transport_pacing.py tests/unit/test_sdk_sync_run.py tests/unit/test_run_scope_lint.py tests/unit/test_mentor_guide.py tests/unit/test_standalone_skills.py: 293 passed. A call inside a scope tomemory.promoteand togrants.listcarries the header; a call before and after the scope carries none, and neither does the scope's ownrun.beginorrun.complete; a recall read carries the header and no bodyrun_id; underauto_runa label passed inextra_headersis the one sent.biome check .,tsc --noEmit, andvitest runon the eight test files that reach the client and the tools (client,code-tools,tools,memory-tool-receipts,model-memory-metadata, and theai-sdk,mastraandopenai-agentsintegrations): 153 passed. The fourrun labelcases cover the op with norun_idfield, a write, a session, the tools (a memory update and a code lookup), a call outside a run, a read labelled through the call option, and an id that is not a header value.ruff format --checkandruff checkon the changed Python files: clean.make typecheck: the mypy gate at 0 errors,mypy --strict sdk/python/loomclean. The function-length gate is at its baseline. Prettier--checkon the three changed pages: clean.pytest -n 2 tests/unit/test_package_contracts.py tests/unit/test_op_transport_contract.py tests/unit/test_tunable_constants.py tests/unit/test_store_names_refused.py tests/unit/test_degraded_unnoted.py tests/unit/test_public_copy.py tests/unit/test_doc_links.py tests/unit/test_agent_instructions.py tests/analyzer: 601 passed, 12 skipped (the analyzer's live cases, which need a ClickHouse; no statement changed).On the first commit's tree, and not run again after the review fixes:
npm --prefix sdk/typescript run check(Biome,tsc, the version and README checks, every unit test): 40 files, 798 tests passed.pytest tests/integration/test_sdk_run_header.py: 1 passed. Theloom.agent_eventsrow of amemory.promotemade inside arun_scopenames the run; the row of one made after the scope closed names none. The review fixes change no path this test takes.Left to CI: the full unit and integration suites,
npm --prefix sdk/typescript run check:dist, the Python SDK wheel smoke andmake test-mixed-version. No generator applies: no op, field, setting or CLI command changed, andskills/loom/is written by hand.AI assistance in the code (leave one; writing this description with AI is fine):
AI-generated (an agent wrote most of the diff): Claude Code. Checked: each statement under Why against the server and SDK code on
main, each new test failing before its fix, and the runs listed under Tests.I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist
make formatandmake lintwere not run as a whole: ruff, the type checks, Biome and Prettier were run on what changed. The fullmake test-unitand applicable integration results are reported by CI; a full local run is not required before pushing.skills/loom/.main; no merged migration is edited. None added.skills/loom/ships with the root package, whose version follows the server's.frontend/changed. Not changed.docs/describe the system as it now is (docs/features/runs.md,docs/reference/python-sdk.md,docs/reference/typescript-sdk.md, and the agent guide inskills/loom/), and this description names any operator steps and wire changes.tests/unit/test_public_copy.pypasses).git commit -s), as CONTRIBUTING.md asks.🤖 Generated with Claude Code