Skip to content

fix: pass provider= kwarg to context_manager.get_messages_for_request#11

Open
bkrabach wants to merge 1 commit into
mainfrom
fix/pass-provider-to-context-manager
Open

fix: pass provider= kwarg to context_manager.get_messages_for_request#11
bkrabach wants to merge 1 commit into
mainfrom
fix/pass-provider-to-context-manager

Conversation

@bkrabach
Copy link
Copy Markdown
Collaborator

Summary

  • The orchestrator loop called context_manager.get_messages_for_request() without provider= kwarg at two sites (__init__.py:158-159, :588-589), silently bypassing the duck-typed budget-resolution cascade in context-simple/persistent/managed.
  • Result: kernel-side token budgeting was inoperative for anyone using loop-events.
  • loop-basic and loop-streaming pass provider= correctly—this was a gaps-in-coverage issue.
  • Fix: add provider=provider at both call sites. Provider was already in local scope (assigned from self._select_provider(providers) at line 142).

Test Plan

  • ✓ 14 existing tests pass
  • ✓ Pre-existing unrelated failure (test_tool_post_no_modify_uses_original) was already broken on main
  • ✓ COE code review: GREEN (approve). One cosmetic suggestion (add explanatory comment) — not a blocker.

Generated with Amplifier

Co-Authored-By: Amplifier 240397093+microsoft-amplifier@users.noreply.github.com

…s_for_request

The context-manager budget resolution cascade (see amplifier-module-context-simple:1157-1223)
reads provider.get_info().defaults["context_window"] and ["max_output_tokens"] via the
provider kwarg. Missing the kwarg silently disables kernel-side token budgeting — the
cascade falls through to the context manager's generic max_tokens fallback (200k default),
producing prompts that overflow smaller servers (llama.cpp, LM Studio, vLLM).

loop-basic and loop-streaming pass provider= correctly at their equivalent sites. This
brings loop-events to parity.

Co-authored-by: Amplifier <amplifier@bkrabach>
hoopsomuah pushed a commit to anokye-labs/amplifier-module-loop-events that referenced this pull request May 6, 2026
…ft#10)

content_models.ThinkingContent has a .text attribute (distinct from
message_models.ThinkingBlock which uses .thinking). The hasattr-based
filter at both the main loop path and the max-iterations fallback was
letting thinking text leak into final_response.

Extracts a shared _extract_text_from_content helper and replaces both
call sites. Same fix pattern as amplifier-module-loop-streaming PR #25
(merge df5c0e1) and amplifier-module-loop-basic PR microsoft#11.

Adds regression tests verifying ThinkingContent is filtered at both
code paths while TextBlock/TextContent pass through.
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