-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: refactor agent memory representation and modify routes for editing blocks #2094
Merged
+1,320
−1,213
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sarahwooders
had a problem deploying
to
Deployment
November 22, 2024 18:43
— with
GitHub Actions
Failure
sarahwooders
had a problem deploying
to
Deployment
November 22, 2024 21:31
— with
GitHub Actions
Failure
sarahwooders
had a problem deploying
to
Deployment
November 23, 2024 02:17
— with
GitHub Actions
Failure
sarahwooders
had a problem deploying
to
Deployment
November 23, 2024 02:26
— with
GitHub Actions
Failure
sarahwooders
had a problem deploying
to
Deployment
November 23, 2024 03:00
— with
GitHub Actions
Failure
sarahwooders
had a problem deploying
to
Deployment
November 23, 2024 03:59
— with
GitHub Actions
Failure
sarahwooders
had a problem deploying
to
Deployment
November 23, 2024 04:21
— with
GitHub Actions
Failure
sarahwooders
had a problem deploying
to
Deployment
November 23, 2024 04:25
— with
GitHub Actions
Failure
sarahwooders
had a problem deploying
to
Deployment
November 25, 2024 17:39
— with
GitHub Actions
Failure
sarahwooders
had a problem deploying
to
Deployment
November 25, 2024 20:18
— with
GitHub Actions
Failure
sarahwooders
had a problem deploying
to
Deployment
November 27, 2024 01:12
— with
GitHub Actions
Failure
sarahwooders
had a problem deploying
to
Deployment
November 27, 2024 02:09
— with
GitHub Actions
Failure
sarahwooders
had a problem deploying
to
Deployment
November 27, 2024 19:30
— with
GitHub Actions
Failure
sarahwooders
had a problem deploying
to
Deployment
November 27, 2024 19:40
— with
GitHub Actions
Failure
sarahwooders
had a problem deploying
to
Deployment
November 27, 2024 19:48
— with
GitHub Actions
Failure
mattzh72
requested changes
Nov 27, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some small bugs left:
FAILED tests/test_memory.py::test_dump_memory_as_json - AttributeError: 'ChatMemory' object has no attribute 'to_dict'
FAILED tests/test_memory.py::test_load_memory_from_json - AttributeError: 'ChatMemory' object has no attribute 'to_dict'
FAILED tests/test_memory.py::test_memory_jinja2_template_load - AttributeError: 'ChatMemory' object has no attribute 'to_dict'
FAILED tests/test_memory.py::test_memory_jinja2_template - AttributeError: 'ChatMemory' object has no attribute 'memory'
FAILED tests/test_memory.py::test_memory_jinja2_set_template - ValueError: Prompt template is not compatible with current memory structure: 'ChatMemory' object has no attribute 'memory'
FAILED tests/test_memory.py::test_link_unlink_block - AttributeError: 'ChatMemory' object has no attribute 'link_block'
FAILED tests/test_memory.py::test_update_block_label - AttributeError: 'ChatMemory' object has no attribute 'update_block_label'. Did you mean: 'update_block_value'?
FAILED tests/test_memory.py::test_update_block_limit - AttributeError: 'ChatMemory' object has no attribute 'update_block_limit'. Did you mean: 'update_block_value'?
FAILED tests/test_summarize.py::test_summarize_messages_inplace - pydantic_core._pydantic_core.ValidationError: 1 validation error for Memory
blocks.0
Input should be a valid dictionary or object to extract fields from [type=model_attributes_type, input_value=None, input_type=NoneType]
For further information visit https://errors.pydantic.dev/2.9/v/model_attributes_type
FAILED tests/test_summarize.py::test_auto_summarize - pydantic_core._pydantic_core.ValidationError: 1 validation error for Memory
blocks.0
Input should be a valid dictionary or object to extract fields from [type=model_attributes_type, input_value=None, input_type=NoneType]
For further information visit https://errors.pydantic.dev/2.9/v/model_attributes_type
sarahwooders
had a problem deploying
to
Deployment
November 27, 2024 22:07
— with
GitHub Actions
Failure
sarahwooders
had a problem deploying
to
Deployment
November 27, 2024 23:18
— with
GitHub Actions
Failure
sarahwooders
had a problem deploying
to
Deployment
November 27, 2024 23:30
— with
GitHub Actions
Failure
sarahwooders
had a problem deploying
to
Deployment
November 27, 2024 23:55
— with
GitHub Actions
Failure
mattzh72
approved these changes
Nov 28, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
overall looks good, some small minor code quality nits, but will probably get cleaned up over time.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Please describe the purpose of this pull request.
This PR aims to resolve bugs resulting from inconsistent agent state and blocks, as well as simplifying the agent creation REST API route.
Changes to agent state
This PR refactors the schemas related to the agent's state:
PersistedAgentState
: This is the schema defining what is persisted in the agents tableCreateAgent
: This is the schema defining the route for agent creation. This PR simplifies is so that memory is created by passing in a list ofCreateBlock
objects, rather than aMemory
objectAgentState
: This schema contains all the state related to an agent contained in process memory, that is passed intoAgent
to instantiate an agent. It contains additional objects like theMemory
object, sources, tools, and tags - since information for these is also contained in separate tables. We use this to both create theAgent
class and also as the return on the clientGET
for agents.Update block routes
This PR also cleans up the routes related to blocks:
block_id
- the block routes are on/blocks/{block_id}
/agents/blocks/{block_label}
route, using theblock_label
as the referenceRemoval of agent caching
We no longer cache agents - agent state must always be read from the DB, and the interface to pass messages to must be passed between functions.
Truncation of error messages
For tool error messages, we add a
MAX_ERROR_MESSAGE_CHAR_LIMIT
constant to limit the size of the error message passed into the context window.Is your PR over 500 lines of code?
Yes