Repository navigation
AG2 recall policies retain session protection across callbacks - #882
Merged
Merged
Conversation
Bind automatic recall to its constructor and callback contributors so client rebinding cannot remove a protected family's authority. Keep model-selected tools explicit and preserve the search payload and prompt behavior. Signed-off-by: zlareb1 <[email protected]>
Exclude proxies before constructing the SDK client so inherited proxy mounts cannot bypass the mock transport. Keep that environment until client closure and check transport selection before any request. Signed-off-by: zlareb1 <[email protected]>
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.
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):
AG2 recall policies retain session protection across callbacks and client rebinding. Protected conversations stop automatic recall before dispatch, while model-selected Loom tools remain explicit operations.
Why
The recall policy sends the latest user message to
memory.searchbefore each model call. It retained neither its constructor's session contributors nor earlier callbacks' contributors, and the search lacked automatic invocation ownership. A protected contributor could therefore send another automatic recall after a client was rebound or an ambient context ended.The policy reuses the shared callback protection helper to retain the application-owned contributors and classify its native
applycallback as automatic. The transport observes a marked response durably before its content reaches the prompt; later automatic callbacks refuse.Scope and risk
The change covers the recall policy, its existing adapter tests and its conversation-ownership documentation. The search arguments, query selection, abstention, ranking filters and prompt format are unchanged.
loom_toolsand its execution helpers are byte-identical to the base.Use one policy per conversation and bind its Loom client to the application's session family. Native user and session ids do not select protection. This adds no session capsule, operation, field or capability declaration. The existing sender census already classifies
memory.search; its call remains visible and no exception or classification changes.The test helper disables inherited proxies before constructing the real SDK client and restores the environment after closing it. HTTPX can select proxy mounts before an assigned mock transport, so replacing only the default transport does not isolate requests. A direct transport-selection check under inherited proxies fails before any network attempt if that isolation breaks; the real SDK request and response hooks remain installed.
Compatibility, rollout and rollback
Tests
Before the fix, seven focused native cases produced six expected missing-refusal failures and one explicit-tool control pass in 1.25 seconds. The cases use the real SDK, native assembly callbacks and an HTTP mock transport. They cover retained constructor and callback contributors, rebinding during authentication, durable marked recall, failed observation and explicit tools.
After the fix, the planned eleven-case check was blocked before launch because available disk space was below the runner's 16 GiB admission floor. No supervisor or local test started, and no local passing result is claimed. Before the test-helper correction, GitHub CI passed all 20 native adapter tests on both supported dependency legs: AG2 1.3.0 with Python 3.11 and AG2 1.3.2 with Python 3.12. Strict adapter mypy also passed in both jobs. The production adapter is byte-identical in the current head; its test helper now isolates inherited proxies and adds one control. On the current head, GitHub CI passes all 21 native cases on both supported legs: 1.09 seconds with AG2 1.3.0/Python 3.11 and 1.07 seconds with AG2 1.3.2/Python 3.12. Strict mypy passes four source files in both jobs. Full required CI passes on this head: all 45 checks are terminal, with 43 successes and two expected publication skips across four successful workflows.
Scoped checks passed:
AI assistance in the code (leave one; writing this description with AI is fine):
AI-generated: An agent wrote the change and checked the callback ownership, unchanged search arguments and explicit-tool implementation.
I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist
docs/describe the behavior, and this description names the operator and wire implications.git commit -s).