GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — api-client-python/docs/sdks/clientagents/README.md at main · gleanwork/api-client-python

Expand file tree

/

README.md

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
386 lines (260 loc) · 61.6 KB
/

README.md

Copy path

File metadata and controls

386 lines (260 loc) · 61.6 KB
Raw
Copy raw file
Download raw file
Outline
Edit and raw actions

Client.Agents

Overview

Available Operations

  • create - Create an agent
  • retrieve - Retrieve an agent ⚠️ Deprecated
  • update - Edit an agent
  • retrieve_schemas - List an agent's schemas ⚠️ Deprecated
  • import_ - Import an agent
  • list - Search agents ⚠️ Deprecated
  • run_stream - Create an agent run and stream the response ⚠️ Deprecated
  • run - Create an agent run and wait for the response ⚠️ Deprecated

create

Create an agent.

Example Usage

from glean.api_client import Glean
import os


with Glean(
    api_token=os.getenv("GLEAN_API_TOKEN"),
) as glean:

    res = glean.client.agents.create()

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
locale Optional[str] ➖ The client's preferred locale in rfc5646 format (e.g. en, ja, pt-BR). If omitted, the Accept-Language will be used. If not present or not supported, defaults to the closest match or en.
timezone_offset Optional[int] ➖ The offset of the client's timezone in minutes from UTC. e.g. PDT is -420 because it's 7 hours behind UTC.
name Optional[str] ➖ The name of the workflow.
transient Optional[bool] ➖ Used to create a transient workflow.
parent_workflow_id Optional[str] ➖ id of the parent workflow for transient workflows
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.WorkflowResult

Errors

Error Type Status Code Content Type
errors.GleanError 4XX, 5XX */*

retrieve

Returns details of an agent created in the Agent Builder.

⚠️ DEPRECATED: Deprecated on 2026-08-25, removal scheduled for 2027-04-15: Use GET /api/agents/{agent_id} instead..

Example Usage

from glean.api_client import Glean
import os


with Glean(
    api_token=os.getenv("GLEAN_API_TOKEN"),
) as glean:

    res = glean.client.agents.retrieve(agent_id="<id>")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
agent_id str ✔️ The ID of the agent.
locale Optional[str] ➖ The client's preferred locale in rfc5646 format (e.g. en, ja, pt-BR). If omitted, the Accept-Language will be used. If not present or not supported, defaults to the closest match or en.
timezone_offset Optional[int] ➖ The offset of the client's timezone in minutes from UTC. e.g. PDT is -420 because it's 7 hours behind UTC.
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.Agent

Errors

Error Type Status Code Content Type
errors.ErrorResponse 404 application/json
errors.GleanError 4XX, 5XX */*

update

Creates a draft or publishes an agent. Use isDraft=true to save a draft, or isDraft=false (or omit) to publish immediately. Only draft and publish modes are supported.

Example Usage

from glean.api_client import Glean
import os


with Glean(
    api_token=os.getenv("GLEAN_API_TOKEN"),
) as glean:

    glean.client.agents.update(agent_id="<id>")

    # Use the SDK ...

Parameters

Parameter Type Required Description
agent_id str ✔️ The ID of the agent.
locale Optional[str] ➖ The client's preferred locale in rfc5646 format (e.g. en, ja, pt-BR). If omitted, the Accept-Language will be used. If not present or not supported, defaults to the closest match or en.
timezone_offset Optional[int] ➖ The offset of the client's timezone in minutes from UTC. e.g. PDT is -420 because it's 7 hours behind UTC.
name Optional[str] ➖ The name of the workflow.
id Optional[str] ➖ The workflow ID we want to update.
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Errors

Error Type Status Code Content Type
errors.ErrorResponse 404 application/json
errors.GleanError 4XX, 5XX */*

retrieve_schemas

Return agent's input and output schemas. You can use these schemas to detect changes to an agent's input or output structure.

⚠️ DEPRECATED: Deprecated on 2026-08-25, removal scheduled for 2027-04-15: Use GET /api/agents/{agent_id}/schemas instead..

Example Usage

from glean.api_client import Glean
import os


with Glean(
    api_token=os.getenv("GLEAN_API_TOKEN"),
) as glean:

    res = glean.client.agents.retrieve_schemas(agent_id="<id>")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
agent_id str ✔️ The ID of the agent.
locale Optional[str] ➖ The client's preferred locale in rfc5646 format (e.g. en, ja, pt-BR). If omitted, the Accept-Language will be used. If not present or not supported, defaults to the closest match or en.
timezone_offset Optional[int] ➖ The offset of the client's timezone in minutes from UTC. e.g. PDT is -420 because it's 7 hours behind UTC.
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.AgentSchemas

Errors

Error Type Status Code Content Type
errors.ErrorResponse 404, 422 application/json
errors.GleanError 4XX, 5XX */*

import_

Imports an agent from its on-disk folder representation (spec.yaml, instructions.md, skills/, subagents/) packaged as a zip, and creates or updates the agent. Inverse of the export flow: the folder-to-schema conversion runs server-side. The bundle must contain only regular files; symlinks are resolved by the caller at packaging time.

Example Usage

from glean.api_client import Glean, models
import os


with Glean(
    api_token=os.getenv("GLEAN_API_TOKEN"),
) as glean:

    res = glean.client.agents.import_(agent_id="<id>", bundle={
        "file_name": "example.file",
        "content": open("example.file", "rb"),
    }, version_source=models.VersionSource.USER)

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
agent_id str ✔️ The ID of the agent to create or update.
bundle models.Bundle ✔️ Zip of the agent folder (spec.yaml, instructions.md, skills/, subagents/) with symlinks dereferenced.
locale Optional[str] ➖ The client's preferred locale in rfc5646 format (e.g. en, ja, pt-BR). If omitted, the Accept-Language will be used. If not present or not supported, defaults to the closest match or en.
timezone_offset Optional[int] ➖ The offset of the client's timezone in minutes from UTC. e.g. PDT is -420 because it's 7 hours behind UTC.
git_commit_sha Optional[str] ➖ Optional Git commit SHA to associate with this import.
git_author_id Optional[str] ➖ Optional VCS commit author ID to associate with this import.
commit_message Optional[str] ➖ Optional commit message for the imported version.
sync_mode Optional[models.ImportAgentSyncMode] ➖ Whether the imported version is staged (saved without updating the live version) or published directly to the live version.
version_source Optional[models.VersionSource] ➖ Provenance recorded on the staged commit or published version this import produces. Doesn't change the agent's management mode (workflowSource). GIT: synced from a Git repository. USER: uploaded by a user. Defaults to USER when omitted. Ignored for transient imports.
published_baseline_hash Optional[str] ➖ Optional baseline hash of the currently published agent definition. When publish hash validation is enabled, an import updating an existing agent with syncMode PUBLISHED is rejected with HTTP 409 if the current published definition hash is nonempty and does not match this baseline. Leading and trailing whitespace is trimmed; omitted or blank values skip validation. Ignored for STAGED imports, new agents, and transient previews.
is_draft Optional[bool] ➖ Deprecated. Draft mutation semantics are not supported for transient previews. Use transient and parentWorkflowId instead.
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.ImportAgentResponse

Errors

Error Type Status Code Content Type
errors.ErrorResponse 404 application/json
errors.GleanError 4XX, 5XX */*

list

Search for agents by agent name.

⚠️ DEPRECATED: Deprecated on 2026-08-25, removal scheduled for 2027-04-15: Use POST /api/agents/search instead..

Example Usage

from glean.api_client import Glean
import os


with Glean(
    api_token=os.getenv("GLEAN_API_TOKEN"),
) as glean:

    res = glean.client.agents.list(name="HR Policy Agent")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
name Optional[str] ➖ Filters on the name of the agent. The keyword search is case-insensitive. If search string is ommited or empty, acts as no filter. HR Policy Agent
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.SearchAgentsResponse

Errors

Error Type Status Code Content Type
errors.ErrorResponse 404, 422 application/json
errors.GleanError 4XX, 5XX */*

run_stream

Executes an agent run and returns the result as a stream of server-sent events (SSE). Note: If the agent uses an input form trigger, all form fields (including optional fields) must be included in the input object.

⚠️ DEPRECATED: Deprecated on 2026-08-25, removal scheduled for 2027-04-15: Use POST /api/agents/{agent_id}/runs with stream=true instead..

Example Usage

from glean.api_client import Glean
import os


with Glean(
    api_token=os.getenv("GLEAN_API_TOKEN"),
) as glean:

    res = glean.client.agents.run_stream(agent_id="<id>", messages=[
        {
            "role": "USER",
        },
    ])

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
agent_id str ✔️ The ID of the agent to run.
input Dict[str, Any] ➖ The input to the agent. Required when the agent uses an input form trigger.
messages List[models.MessageInput] ➖ The messages to pass an input to the agent.
metadata Dict[str, Any] ➖ The metadata to pass to the agent.
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

str

Errors

Error Type Status Code Content Type
errors.ErrorResponse 404, 409 application/json
errors.UnauthorizedAgentToolsError 422 application/json
errors.GleanError 4XX, 5XX */*

run

Executes an agent run and returns the final response. Note: If the agent uses an input form trigger, all form fields (including optional fields) must be included in the input object.

⚠️ DEPRECATED: Deprecated on 2026-08-25, removal scheduled for 2027-04-15: Use POST /api/agents/{agent_id}/runs instead..

Example Usage

from glean.api_client import Glean
import os


with Glean(
    api_token=os.getenv("GLEAN_API_TOKEN"),
) as glean:

    res = glean.client.agents.run(agent_id="<id>", messages=[
        {
            "role": "USER",
        },
    ])

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
agent_id str ✔️ The ID of the agent to run.
input Dict[str, Any] ➖ The input to the agent. Required when the agent uses an input form trigger.
messages List[models.MessageInput] ➖ The messages to pass an input to the agent.
metadata Dict[str, Any] ➖ The metadata to pass to the agent.
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.AgentRunWaitResponse

Errors

Error Type Status Code Content Type
errors.UnauthorizedAgentToolsError 422 application/json
errors.GleanError 4XX, 5XX */*
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.