Base context
Abstract base class for context management in PyAgenity agent graphs.
This module provides BaseContextManager, which defines the interface for trimming and managing message context in agent state objects.
Classes:
Name | Description |
---|---|
BaseContextManager |
Abstract base class for context management in AI interactions. |
Attributes:
Name | Type | Description |
---|---|---|
S |
|
|
logger |
|
Attributes¶
Classes¶
BaseContextManager
¶
Bases: ABC
Abstract base class for context management in AI interactions.
Subclasses should implement trim_context
as either a synchronous or asynchronous method.
Generic over AgentState or its subclasses.
Methods:
Name | Description |
---|---|
atrim_context |
Trim context based on message count asynchronously. |
trim_context |
Trim context based on message count. Can be sync or async. |
Source code in pyagenity/state/base_context.py
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 |
|
Functions¶
atrim_context
abstractmethod
async
¶
atrim_context(state)
Trim context based on message count asynchronously.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
S
|
The state containing context to be trimmed. |
required |
Returns:
Type | Description |
---|---|
S
|
The state with trimmed context. |
Source code in pyagenity/state/base_context.py
43 44 45 46 47 48 49 50 51 52 53 54 |
|
trim_context
abstractmethod
¶
trim_context(state)
Trim context based on message count. Can be sync or async.
Subclasses may implement as either a synchronous or asynchronous method.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
S
|
The state containing context to be trimmed. |
required |
Returns:
Type | Description |
---|---|
S
|
The state with trimmed context, either directly or as an awaitable. |
Source code in pyagenity/state/base_context.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
|