Skip to content

[Bug][multi-agent-shared-context]: before_acting() reads a 'memories' key the SDK never returns, so agents always report 0 retrieved memories #475

Open
smaramwbc/statewave-multi-agent-shared-context
#6

Description

@jy7lsna

Affected Component

statewave-multi-agent-shared-context — statewave_agents/context.py, agents/coder.py, agents/reviewer.py

Bug Description

SharedContext.before_acting() builds its ContextBundle from a key the SDK never returns:

# statewave_agents/context.py:110-113
return ContextBundle(
    assembled_context=response.get("assembled_context", ""),
    memories=response.get("memories", []),
)

response is statewave.ContextBundle.model_dump(), whose fields are:

>>> list(statewave.ContextBundle.model_fields)
['subject_id', 'task', 'facts', 'episodes', 'procedures', 'provenance',
 'assembled_context', 'token_estimate', 'receipt_id', 'receipt_emitted']

There is no memories key, so bundle.memories is always []. Knock-on effects:

  • ContextBundle.has_context() (line 37) is always False, so agents/coder.py:56 always prints "No compiled memories found in shared context yet." even when the planner's decisions were retrieved.
  • agents/reviewer.py:66 always logs "Retrieved 0 memory item(s)".
  • used_shared_context in both agents' output is always False.
  • memories_of_kind() (line 41) filters on m.get("type"), but SDK memories carry kind, not type — so it would still return nothing after the key is fixed. Same for the mem.get('type', 'memory') label at agents/coder.py:61.

The LLM still receives assembled_context, so answers look fine — only the "what did I retrieve" side of the demo is wrong, which is the part the demo exists to show.

Expected Behavior

bundle.memories holds the retrieved memories, and the coder/reviewer logs report the real count.

Suggested fix

Read facts (plus procedures if you want them shown) instead of memories, and switch type → kind in memories_of_kind() and agents/coder.py:61.

Steps to Reproduce

Run python main.py against a local Statewave. The planner writes decisions, then the coder logs "No compiled memories found in shared context yet." while its prompt contains them.

Environment

main @ eb66ddc; statewave SDK from PyPI.

Severity

Low–medium — no data loss, but the reference implementation misreports the exact thing it demonstrates. Related: #400 (same files, different bug).

Activity

  1. g-seo commented on Oct 6, 2026

    @g-seo
    Contributor

    I'd like to work on this issue.
    I'll keep the fix narrowly scoped to the SDK response-mapping bug:

    I'll verify that has_context(), kind filtering, and the coder/reviewer retrieval counts reflect the SDK response correctly.
    /claim

  2. g-seo commented on Oct 26, 2026

    @g-seo
    Contributor

    I've opened a PR to fix this issue: smaramwbc/statewave-multi-agent-shared-context#6

    Would appreciate a review when you have a chance. Thanks!

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions