Skip to content

History session data with mysql db session service didn't display as expected time order #941

@Colstuwjx

Description

@Colstuwjx

** Please make sure you read the contribution guide and file the issues in the right place. **
Contribution guide.

Describe the bug
I've used pymysql and database session service to store the adk chat session data, however, it seems like the session chat data didn't show as expected.

Image

related api: GET http://127.0.0.1:8080/apps/my_agent/users/user/sessions/1be66d52-36e3-4092-99cb-a795957d0680

api response data:

...
        {
            "content": {
                "parts": [
                    {
                        "text": "I need to transfer to the `knowledge_retrieve_agent` to retrieve the document.\n\n"
                    },
                    {
                        "functionCall": {
                            "id": "adk-8f521665-f854-4a76-b4cd-b03d8677ab0c",
                            "args": {
                                "agent_name": "knowledge_retrieve_agent"
                            },
                            "name": "transfer_to_agent"
                        }
                    }
                ],
                "role": "model"
            },
            "invocationId": "e-a647fe88-20dd-4ecc-b3a5-3fa982efc40d",
            "author": "problem_analysis_agent",
            "actions": {
                "stateDelta": {},
                "artifactDelta": {},
                "requestedAuthConfigs": {}
            },
            "longRunningToolIds": [],
            "id": "fzfUoYlX",
            "timestamp": 1748243390.0
        },
        {
            "content": {
                "parts": [
                    {
                        "text": "please use rag to retrieval the doc "
                    }
                ],
                "role": "user"
            },
            "invocationId": "e-a647fe88-20dd-4ecc-b3a5-3fa982efc40d",
            "author": "user",
            "actions": {
                "stateDelta": {},
                "artifactDelta": {},
                "requestedAuthConfigs": {}
            },
            "longRunningToolIds": [],
            "id": "zgrx7klz",
            "timestamp": 1748243390.0
        },
...

As we can see, the timestamp same to be 1748243390.0, I'm wondering if it's the root cause.

To Reproduce
Steps to reproduce the behavior:

  1. Install google-adk==1.0.0 and pymysql, use mysql as session storage
  2. Run 'uvicorn main:app --host 0.0.0.0 --port 8080' to start the adk web service
  3. Open 'http://127.0.0.1:8080' and try to chat several rounds with the agent, close and re-open it
  4. You may see the disorder issue as well

Expected behavior
chat history should be ordered by the original asking order.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: macOS
  • Python version(python -V): 3.12.7
  • ADK version(pip show google-adk): 1.0.0

Additional context

Metadata

Metadata

Assignees

Labels

services[Component] This issue is related to runtime services, e.g. sessions, memory, artifacts, etc

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions