strands.agent.state
¶
Agent state management.
AgentState = JSONSerializableDict
module-attribute
¶
JSONSerializableDict
¶
A key-value store with JSON serialization validation.
Provides a dict-like interface with automatic validation that all values are JSON serializable on assignment.
Source code in strands/types/json_dict.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | |
__init__(initial_state=None)
¶
Initialize JSONSerializableDict.
Source code in strands/types/json_dict.py
15 16 17 18 19 20 21 22 | |
delete(key)
¶
Delete a specific key from the store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
The key to delete |
required |
Source code in strands/types/json_dict.py
52 53 54 55 56 57 58 59 | |
get(key=None)
¶
Get a value or entire data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str | None
|
The key to retrieve (if None, returns entire data dict) |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
The stored value, entire data dict, or None if not found |
Source code in strands/types/json_dict.py
38 39 40 41 42 43 44 45 46 47 48 49 50 | |
set(key, value)
¶
Set a value in the store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
The key to store the value under |
required |
value
|
Any
|
The value to store (must be JSON serializable) |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If key is invalid, or if value is not JSON serializable |
Source code in strands/types/json_dict.py
24 25 26 27 28 29 30 31 32 33 34 35 36 | |