Skip to content

Send message to the ADK API and display in the chat/session #3722

@zdenulo

Description

@zdenulo

In my workflow, an agent is taking input from a user and, in the tool, submits a long-running job to the outside API. API returns "id" of the job, which the user can then use to query information about the job, i.e., if it is completed and similar.

I'm wondering if there is a way to send an API request to the ADK server from the outside, i.e., in my context, I would like to send a message from the outside system to a user that the job has been completed, and (ideally) it displays in real time in the chat window.

I've tried this code snippet

import requests

url = "http://127.0.0.1:8000/run_sse"
url = "http://127.0.0.1:8000/run"

session_id = 'b8adac74-e070-4c28-b899-a375b07c9258'

data = {
    'app_name': 'chat_agent',
    'user_id': 'user',
    'session_id': session_id,
    'new_message': {
        'parts': [
            {'text': 'Job xx is completed'}
        ],
        'role': 'model'
    }
}

r = requests.post(url, json=data)
print(r.text)

When sending data like this, I only see the message when I reload the Web UI (session), and it appears as if it were from a user (not a model) to which the model then responds.
So my questions are:

  1. Can a message be posted as it is from a model (not a user)
  2. Can the update be done in real-time (without reloading the session)

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions