Skip to content

Example: shared memory coordination between agents #26

@JackChen-me

Description

@JackChen-me

Context

Current examples enable sharedMemory: true (examples 02, 03) but the read/write mechanism is invisible to users. No example demonstrates explicit use of SharedMemory.write() / read() / getSummary() or the team.on() event system.

Proposed example: 08-shared-memory.ts

Two agents collaborate through explicit shared memory:

  • researcher writes structured findings to SharedMemory
  • writer reads from SharedMemory and produces an article
  • Print mem.getSummary() output so users can see what's being shared
  • Use team.on('task:complete', ...) for progress monitoring

APIs to showcase

  • SharedMemory.write(agentName, key, value)
  • SharedMemory.read(key)
  • SharedMemory.getSummary()
  • team.getSharedMemory()
  • team.on() event subscriptions

Acceptance criteria

  • File at examples/08-shared-memory.ts
  • npx tsx examples/08-shared-memory.ts runs successfully
  • npm run lint passes
  • Style consistent with existing examples (header comment, section separators, progress output)

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Backlog — revisit after core stabilizesdocumentationImprovements or additions to documentationenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions