-
Notifications
You must be signed in to change notification settings - Fork 40
Expand file tree
/
Copy path16e_credentials_http_tool.py
More file actions
62 lines (50 loc) · 2.11 KB
/
Copy path16e_credentials_http_tool.py
File metadata and controls
62 lines (50 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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
55
56
57
58
59
60
61
# Copyright (c) 2025 Agentspan
# Licensed under the MIT License. See LICENSE file in the project root for details.
"""Credentials — HTTP tool with server-side credential resolution.
Demonstrates:
- http_tool() with credentials=["GITHUB_TOKEN"]
- ${GITHUB_TOKEN} in headers resolved server-side (not in Python)
- No worker process needed — Conductor makes the HTTP call directly
The ${NAME} syntax in headers tells the server to substitute the credential
value from the store at execution time. The plaintext value never appears
in the workflow definition.
Setup (one-time):
agentspan credentials set GITHUB_TOKEN <your-github-token>
Requirements:
- Agentspan server running at AGENTSPAN_SERVER_URL
- AGENTSPAN_LLM_MODEL set (or defaults to openai/gpt-5.4)
- GITHUB_TOKEN stored via `agentspan credentials set`
"""
from conductor.ai.agents import Agent, AgentRuntime
from conductor.ai.agents.tool import http_tool
from settings import settings
# HTTP tool with credential-bearing headers.
# ${GITHUB_TOKEN} is resolved server-side from the credential store.
list_repos = http_tool(
name="list_github_repos",
description="List public GitHub repositories for a user. Returns JSON array with name, url, and stars.",
url="https://api.github.com/users/agentspan/repos?per_page=5&sort=updated",
headers={
"Authorization": "Bearer ${GITHUB_TOKEN}",
"Accept": "application/vnd.github.v3+json",
},
credentials=["GITHUB_TOKEN"],
)
agent = Agent(
name="github_http_agent",
model=settings.llm_model,
tools=[list_repos],
instructions="You list GitHub repos using the list_github_repos tool. Summarize the results.",
)
if __name__ == "__main__":
with AgentRuntime() as runtime:
result = runtime.run(agent, "List the repos for agentspan")
result.print_result()
# Production pattern:
# 1. Deploy once during CI/CD:
# runtime.deploy(agent)
# CLI alternative:
# agentspan deploy --package examples.16e_credentials_http_tool
#
# 2. In a separate long-lived worker process:
# runtime.serve(agent)