Skip to content

Native conversation history retains contributor protection - #859

Merged
zlareb1 merged 14 commits into
mainfrom
feat/native-history-session-protection
Nov 18, 2026
Merged

zlareb1 merged 14 commits into
mainfrom
feat/native-history-session-protection

Conversation

@zlareb1

@zlareb1 zlareb1 commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Related: #840
Related: #849
Related: #850
Related: #861

Changelog category (leave one):

  • Improvement

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):

Python and TypeScript native conversation history retain protection for its contributing conversation families across client rebinding. Marked replies stop later automatic history reads and writes while explicit history deletion remains available.

Why

The native session can outlive its creating context and use a rebound Loom client. Looking only at the current client loses the original conversation's protection authority. Retaining constructor and callback contributors keeps that authority with the conversation instance.

Scope and risk

Both native session implementations retain constructor-bound and callback-bound client families; Python also retains ambient callback contributors through the private framework helper. History reads and additions use the existing automatic SDK controls; each item write checks protection before the next item. Response observation still runs before content returns, including through credential refresh.

A first complete marked history reply may return its items after durable protection. Further pagination, hydration and automatic writes refuse. Explicit pop and clear operations retain response observation without capture suppression. Model-selected tools keep their explicit behavior. Each instance belongs to one logical conversation family; restoring it requires the same application-owned capsule. Native user and session ids only route stored history.

The sender inventory renews the two reviewed adapter source hashes and moves four TypeScript reference keys whose invocation-control arguments changed. Operation names, wire payloads and exception categories and reasons remain unchanged. No capsule, host binding, capability declaration or platform qualification is added.

Compatibility, rollout and rollback

  • Wire: no operation, field, header or public method signature changes.
  • Storage: no schema or durable capsule format change.
  • Operators: none. Applications bind existing complete contributor authority before construction and retain the same capsule on restore.
  • Rollback: no migration. Preserve durable protection records; older adapters cannot declare session protection support.

Tests

  • Each language has an independent focused causal cohort: 11 protection failures before the fix while two existing ordinary controls pass.
  • The same Python 13 cases pass after the fix in 2.82 seconds, using the installed native session protocol and HTTPX MockTransport.
  • The same TypeScript 13 cases pass after the fix in 45 ms test time and 786 ms total. It uses real Agent and native session objects with injected fetch; a promise-controlled durability case verifies that both contributing families commit protection before history returns. No service or provider starts.
  • Cases cover constructor and ambient contributors, client rebinding, a marked first history reply, later callback retention, batch and pagination stops, credential waits, and explicit pop/clear observation. Existing ordered paginated history and pop controls pass.
  • Reproduce the focused regression cases with pytest -q sdk/python/tests/test_openai_agents.py -k "native_history or keeps_items_in_order_across_pages_and_repeats or pop_item_removes_and_returns_the_latest_item".
  • Reproduce the TypeScript cohort from the SDK directory with vitest run --pool=forks --maxWorkers=1 --no-file-parallelism src/integrations/openai-agents.test.ts -t "LoomSession conversation protection|keeps items in order across pages, with repeats|pops the latest item and clears only its own session".
  • The existing sender-census admission/provenance case passes in 4.92 seconds, including both precise source-pin renewals and the four reference-key moves. All other classifications and source pins remain intact.
  • Scoped Ruff and Biome formatting/lint, strict typing of the changed Python modules and TypeScript module/test with the repository compiler options, documentation formatting, prose and diff checks pass.
  • A unit shard exposed an existing restore business fixture whose fresh fake lock uses a real 0.3-second admission budget. The fixture uses one local manual clock for key-lock, lease and fake-store time while preserving real lock algorithms, timeout values and all business assertions. The existing late-Undo pair and eight lock/refusal controls pass in a targeted check; production clocks and lock tests are unchanged.
  • The hosted Java lane-cost check reported two unexplained CPU ratios with unassigned parser failures. The existing lane diagnostic change is composed to attribute each sample to its shape, size, completion state and error. It preserves the workload, cost judge, thresholds and parser bounds; no Java fix is claimed.
  • Full unit, native SDK adapter, package and integration checks run in GitHub CI and must pass on the final head. No broad local suite ran.

AI assistance in the code (leave one; writing this description with AI is fine):

  • AI-generated: Codex wrote the change; fresh independent whole-diff review and final-head CI are required before merge.

  • I can explain every line of this diff and how it interacts with the rest of Loom.

Checklist

  • Full final-head CI passes.
  • Fresh whole-diff review has no findings or nits.
  • Documentation states conversation ownership, suppression and restore requirements.
  • No operation generator, migration, plugin or frontend changes.
  • Public text follows repository copy rules.
  • Commits are signed off.

Observe the native response body before releasing marked frames and keep every contributing handle across buffered automatic work. Explicit actions retain observation without becoming automatic capture.

Signed-off-by: zlareb1 <[email protected]>
A shared monotonic patch could expire a freshly loaded model-call policy before the bearer test reached its first request. Exercise the same attributed token rotation at two clock epochs without changing the policy clock.

Signed-off-by: zlareb1 <[email protected]>
Keep constructor and callback contributors across client rebinding. Treat history reads and additions as automatic work while preserving observed explicit pop and clear operations.

Signed-off-by: zlareb1 <[email protected]>
Keep diagnostics attached to the naturally attempted shape and size so a cost failure identifies its own incomplete parse or walk. Keep the original timing judge, inputs and limits.

Signed-off-by: zlareb1 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>

# Conflicts:
#	tests/unit/test_code_regex_cost.py
Compose the existing lane diagnostics so hosted CI records each failing size and completion state. Keep the cost workload, thresholds, parser bounds and native history implementation unchanged.

Signed-off-by: zlareb1 <[email protected]>
@zlareb1
zlareb1 merged commit 15f60c3 into main Nov 18, 2026
45 checks passed
@zlareb1 zlareb1 mentioned this pull request Nov 18, 2026
6 tasks done
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