Skip to content

[Bug][multi-agent-shared-context]: top_k is accepted at three layers and silently dropped - the SDK has no such parameter #400

Description

@jy7lsna

Affected Component

statewave-multi-agent-shared-contextcore/statewave_client.py, statewave_agents/context.py, statewave_agents/agent.py

Bug Description

top_k is threaded through three layers of the public demo API and then dropped on the floor.

  • statewave_agents/agent.py:34def run(self, task: str, top_k: int = 5)
  • statewave_agents/context.py:102def before_acting(self, caller_id, task, top_k: int = 5), passes it on at line 108
  • core/statewave_client.py:54def get_context(..., top_k: int = 5) accepts it, and the self._sdk.get_context(...) call at lines 57-61 never references it

So every caller that sets top_k believes it is controlling retrieval breadth, and nothing happens.

It isn't a one-line forward, either — the SDK has no such parameter:

>>> import statewave, inspect
>>> inspect.signature(statewave.StatewaveClient.get_context)
(self, subject_id: str, task: str, *, max_tokens: int | None = None, session_id: str | None = None,
 emit_receipt: bool | None = None, query_id: str | None = None, task_id: str | None = None,
 caller_id: str | None = None, caller_type: str | None = None) -> ContextBundle

Retrieval breadth is bounded by max_tokens, not a top-k count.

Expected Behavior

Either drop top_k from all three signatures, or rename it to max_tokens and forward it, so the knob the demo exposes is the knob the server actually has.

Steps to Reproduce

Call agent.run(task, top_k=1) and agent.run(task, top_k=50) against a subject with many memories and compare the bundles — they are identical.

Environment

main as of 2026-09-07; statewave Python SDK as installed from PyPI.

Severity

Low — no data loss, but it is a public parameter of a reference implementation that does nothing, and people copy reference implementations.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions