fix(mcp): pass the retain strategy to the worker - #3296
Open
fhiltscher wants to merge 1 commit into
Open
Conversation
The async retain tool built the strategy into the content dict and then called submit_async_retain without it. That method only writes a strategy into the task payload when it is passed as the keyword argument, so the worker never saw one: apply_strategy() did not run and every strategy override — mission, entity labels, chunk size, free-form setting — fell back to the bank configuration, silently. Pass it the way sync_retain right below already does. The REST endpoint is unaffected; api_retain groups items by strategy and forwards it.
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.
Summary
The MCP
retaintool accepts astrategybut never delivers it to the worker, so every strategy override is silently ignored and the bank-level configuration is used instead.build_content_dictputs the strategy into the content item, and the call passes only the contents:submit_async_retainwrites the strategy into the task payload from its own keyword argument only:Nothing reads a strategy back out of the content items, so the payload has none,
apply_strategy()never runs, andretain_mission,entity_labels,retain_chunk_sizeandentities_allow_free_formall fall back to the bank config. No error, no warning.Both async
retainregistrations are affected.sync_retain, a few lines below, already does it correctly — this PR applies the same idiom:api_retain(REST) is unaffected: it groups items byitem.strategyand forwards it.Impact
Measured on a bank whose
canonical_documentstrategy restrictsrecord_typetostate,rule,procedurevia per-strategyentity_labels, importing the same three documents twice:analysis, 1decision)The illegal values are only possible because the bank-level vocabulary was in force — with the strategy's
entity_labelsapplied,build_labels_model()turns them into aLiteral[...]that structured output cannot violate.Worth noting for triage: the dry-run extract endpoint cannot reveal this, because it strips the extracted labels from its response. The defect is only visible in the stored facts, where it looks like model non-compliance rather than lost configuration.
Test
test_retain_passes_strategy_to_the_workerasserts thatsubmit_async_retainreceivesstrategyas a keyword. It fails without the change; the existingTestRetainNewParamscases keep passing.tests/test_mcp_tools.py: 201 passed../scripts/hooks/lint.shpasses.