agentfield icon indicating copy to clipboard operation
agentfield copied to clipboard

[Python SDK] Document memory scope hierarchy

Open santoshkumarradha opened this issue 11 months ago • 17 comments

Summary

The Python SDK memory module supports different scopes (global, session, actor, workflow) but lacks documentation explaining the scope hierarchy and when to use each scope.

Current State

  • File: sdk/python/agentfield/memory.py
  • Issue: Scope hierarchy and use cases not documented

Tasks

Add comprehensive documentation explaining:

  1. Available scopes: List all memory scopes with descriptions
  2. Scope hierarchy: Explain how scopes relate to each other
  3. Use cases: When to use each scope
  4. Lifecycle: When data in each scope is cleared
  5. Examples: Code examples for common patterns

Documentation Content

"""
Memory Scope Hierarchy
======================

AgentField provides four memory scopes for storing agent data:

Global Scope
------------
- Shared across all agents and sessions
- Persists until explicitly deleted
- Use for: Configuration, shared knowledge bases, cross-agent state

Session Scope  
-------------
- Scoped to a single user session (conversation)
- Cleared when session ends
- Use for: Conversation context, user preferences within a session

Actor Scope
-----------
- Scoped to a single agent across all sessions
- Persists across sessions
- Use for: Agent-specific learned data, agent configuration

Workflow Scope (Run Scope)
--------------------------
- Scoped to a single workflow execution
- Cleared when workflow completes
- Use for: Intermediate results, execution-specific state

Hierarchy Diagram
-----------------
    Global (widest)
        |
    Session
        |
    Actor
        |
    Workflow/Run (narrowest)

Example Usage
-------------
>>> # Store in global scope
>>> await agent.memory.set("config", value, scope="global")
>>> 
>>> # Store in session scope  
>>> await agent.memory.set("context", value, scope="session")
"""

Acceptance Criteria

  • [ ] Module-level docstring explains all scopes
  • [ ] Each scope has a clear description and use case
  • [ ] Include hierarchy diagram (ASCII art)
  • [ ] Include code examples
  • [ ] Documentation renders correctly with help(memory)

Files

  • sdk/python/agentfield/memory.py

Using AI to solve this issue? Read our AI-Assisted Contributions guide for testing requirements, prompt strategies, and common pitfalls to avoid.

santoshkumarradha avatar Dec 23 '25 16:12 santoshkumarradha

Hello! This is my first issue. May I start with this one?

1khazipov avatar Feb 17 '26 18:02 1khazipov

hey @1khazipov all yours !

santoshkumarradha avatar Feb 19 '26 03:02 santoshkumarradha

Thanks for picking this up, @1khazipov! :tada:

Here's what to expect:

  • We'll check in after 7 days if we haven't heard an update
  • After 14 days, we'll send a second reminder
  • After 21 days without activity, we'll unassign to let others contribute

Tips for success:

  • Drop a comment when you start working on it
  • Share any blockers - we're here to help!
  • Link your PR with Fixes #121 in the description

Happy coding! :rocket:

github-actions[bot] avatar Feb 19 '26 03:02 github-actions[bot]

Hey @1khazipov! :wave:

Just a friendly reminder that you're assigned to this issue. It's been about a week since assignment.

How's it going? We'd love to hear:

  • Any progress updates?
  • Running into any blockers we can help with?
  • Need more time? (Totally fine!)

A quick comment helps us know you're still interested. If your plans have changed, no worries at all - just let us know and we can find another contributor.

Thanks for contributing to AgentField! :rocket:

github-actions[bot] avatar Feb 25 '26 09:02 github-actions[bot]

Hi @1khazipov,

Just checking in again! It's been 14 days since we last heard from you on this issue.

Quick options:

  • :speech_balloon: Drop a comment with a progress update
  • :link: Link a draft PR if you've started working on it
  • :wave: Let us know if you'd like to be unassigned (no judgment!)

If we don't hear back in 7 days, we'll unassign this issue to give other contributors a chance to help.

Thanks for understanding!

github-actions[bot] avatar Mar 04 '26 09:03 github-actions[bot]

Hi @1khazipov,

It's been 21 days since the last update on this issue. To keep the project moving, we've unassigned this issue so other contributors can pick it up.

No worries at all! Life happens, and we totally understand. If you'd like to continue working on this, just comment here and we'll reassign it to you.

This issue is now available for anyone who'd like to contribute. Check out our contribution guidelines if you're interested!

Thanks for your interest in AgentField! :heart:

github-actions[bot] avatar Mar 11 '26 09:03 github-actions[bot]

I'd like to work on this issue. I'll add comprehensive documentation for the memory scope hierarchy following the acceptance criteria.

meichuanyi avatar Apr 21 '26 22:04 meichuanyi

I noticed the memory.py file already has comprehensive documentation in the module docstring. I've verified it covers all the acceptance criteria:\n\n✅ Module-level docstring explains all scopes\n✅ Each scope has a clear description and use case \n✅ Hierarchy diagram (ASCII art) included\n✅ Code examples included\n✅ Lifecycle documentation included\n\nIs there anything else needed for this issue, or can it be closed? Happy to help verify the documentation renders correctly with if needed.

meichuanyi avatar Apr 21 '26 22:04 meichuanyi

Hi! Following up on my previous comment - I've thoroughly reviewed the memory.py module docstring and it already comprehensively covers all the acceptance criteria:\n\n✅ Module-level docstring explains all 4 scopes (global, session, actor, workflow)\n✅ Each scope has clear description, use cases, and lifecycle info\n✅ Scope hierarchy diagram included (ASCII art)\n✅ Multiple code examples demonstrating usage patterns\n✅ Documentation is well-formatted for help(memory) rendering\n\nThe documentation appears complete! Is there anything specific still needed for this issue, or can it be closed? Happy to help if there's additional work needed. :smile:

meichuanyi avatar Apr 22 '26 00:04 meichuanyi

@maintainer 我来检查了这个 issue,看起来文档已经在 中完成了。

文件顶部有完整的 Memory Scope Hierarchy 文档,包括:

  • 四种 scope 的详细说明(Global/Session/Actor/Workflow)
  • Scope Relationship 图
  • Lookup Behavior 说明
  • Lifecycle and Data Retention
  • 完整的 Example Usage

建议关闭这个 issue,或者如果有遗漏的内容请指出。👍

meichuanyi avatar Apr 22 '26 10:04 meichuanyi

I'd like to work on this issue. I'll add comprehensive documentation for the memory scope hierarchy including all scopes, hierarchy diagram, use cases, and code examples. 🚀

meichuanyi avatar Apr 22 '26 12:04 meichuanyi

hey @santoshkumarradha , Can you please assign this issue to me - I can fix this.

burhanv14 avatar Aug 21 '26 19:08 burhanv14

Thanks for picking this up, @meichuanyi! :tada:

Here's what to expect:

  • We'll check in after 7 days if we haven't heard an update
  • After 14 days, we'll send a second reminder
  • After 21 days without activity, we'll unassign to let others contribute

Tips for success:

  • Drop a comment when you start working on it
  • Share any blockers - we're here to help!
  • Link your PR with Fixes #121 in the description

Happy coding! :rocket:

github-actions[bot] avatar Aug 21 '26 22:08 github-actions[bot]

Thanks for picking this up, @burhanv14! :tada:

Here's what to expect:

  • We'll check in after 7 days if we haven't heard an update
  • After 14 days, we'll send a second reminder
  • After 21 days without activity, we'll unassign to let others contribute

Tips for success:

  • Drop a comment when you start working on it
  • Share any blockers - we're here to help!
  • Link your PR with Fixes #121 in the description

Happy coding! :rocket:

github-actions[bot] avatar Aug 21 '26 22:08 github-actions[bot]

hey @santoshkumarradha , Can you please assign this issue to me - I can fix this.

Yes sir!

santoshkumarradha avatar Aug 21 '26 22:08 santoshkumarradha

hey @santoshkumarradha ,

The memory module documentation is already complete in sdk/python/agentfield/memory.py:1-99. It covers:

  • All four scopes (global, session, actor, workflow) with descriptions, persistence behavior, and use cases
  • Hierarchy diagram (ASCII) showing scope relationships
  • Lookup behavior explaining the workflow → session → actor → global resolution order
  • Lifecycle/retention details for each scope
  • Code examples for both the accessor API (app.memory.session(...).set(...)) and low-level MemoryClient with explicit scope/scope_id kwargs The module-level docstring renders correctly with help(memory). No changes needed - this issue can be closed or marked complete.

If there are any further changes required on the same, happy to contribute!

burhanv14 avatar Aug 22 '26 18:08 burhanv14

Thanks for digging into this @burhanv14 — your read is right, and I verified it.

The docstring is at memory.py:1-99 exactly as you said, and it landed in #184 back in February. That PR just didn't say "Fixes #121" in its body, so this stayed open for six months. I checked all five acceptance boxes against help(agentfield.memory) — all present, and the documented workflow -> session -> actor -> global lookup order matches what the control plane actually does (handlers/memory.go:273).

Closing as completed. Two things I noticed that are worth follow-ups: the ASCII diagram draws Global → Session → Actor → Workflow as one nested chain, but session and actor are really siblings (different headers), so it reads a bit misleadingly; and the "removed automatically when the run completes" retention wording doesn't match what the control plane does today (there's no automatic purge). We'll correct both.

AbirAbbas avatar Aug 26 '26 14:08 AbirAbbas