Skip to content

Commit 3eb0307

Browse files
Update filekeys and add a test
1 parent 0e4502c commit 3eb0307

30 files changed

+134
-80
lines changed

.github/workflows/basictest.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Basic test - run the examples to check for errors
2+
3+
on:
4+
pull_request
5+
6+
permissions:
7+
contents: read
8+
9+
jobs:
10+
Linux:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Setup Python
14+
uses: actions/setup-python@v5
15+
16+
- name: Checkout
17+
uses: actions/checkout@v3
18+
19+
- name: Setup Python venv
20+
run: |
21+
python -m venv .venv
22+
source .venv/bin/activate
23+
python -m pip install -r requirements.txt
24+
25+
- name: Run tests
26+
env:
27+
COPILOT_TOKEN: ${{ secrets.COPILOT_TOKEN }}
28+
run: |
29+
python main.py -p GitHubSecurityLab/seclab-taskflow-agent/personalities/assistant 'explain modems to me please'
30+
python main.py -p GitHubSecurityLab/seclab-taskflow-agent/personalities/c_auditer 'explain modems to me please'
31+
python main.py -p GitHubSecurityLab/seclab-taskflow-agent/personalities/examples/echo 'explain modems to me please'
32+
python main.py -t GitHubSecurityLab/seclab-taskflow-agent/taskflows/CVE-2023-2283/CVE-2023-2283
33+
python main.py -t GitHubSecurityLab/seclab-taskflow-agent/taskflows/examples/echo
34+
python main.py -t GitHubSecurityLab/seclab-taskflow-agent/taskflows/examples/example
35+
python main.py -t GitHubSecurityLab/seclab-taskflow-agent/taskflows/examples/example_globals
36+
python main.py -t GitHubSecurityLab/seclab-taskflow-agent/taskflows/examples/example_inputs
37+
python main.py -t GitHubSecurityLab/seclab-taskflow-agent/taskflows/examples/example_large_list_result_iter
38+
python main.py -t GitHubSecurityLab/seclab-taskflow-agent/taskflows/examples/example_repeat_prompt
39+
python main.py -t GitHubSecurityLab/seclab-taskflow-agent/taskflows/examples/example_repeat_prompt_async
40+
python main.py -t GitHubSecurityLab/seclab-taskflow-agent/taskflows/examples/example_repeat_prompt_dictionary
41+
python main.py -t GitHubSecurityLab/seclab-taskflow-agent/taskflows/examples/example_reusable_prompt
42+
python main.py -t GitHubSecurityLab/seclab-taskflow-agent/taskflows/examples/example_reusable_taskflows
43+
python main.py -t GitHubSecurityLab/seclab-taskflow-agent/taskflows/examples/example_triage_taskflow
44+
python main.py -t GitHubSecurityLab/seclab-taskflow-agent/taskflows/examples/single_step_taskflow

main.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from typing import Any
2525

2626
from shell_utils import shell_tool_call
27-
from mcp_utils import DEFAULT_MCP_CLIENT_SESSION_TIMEOUT, ReconnectingMCPServerStdio, AsyncDebugMCPServerStdio, MCPNamespaceWrap, mcp_client_params, mcp_system_prompt, StreamableMCPThread
27+
from mcp_utils import DEFAULT_MCP_CLIENT_SESSION_TIMEOUT, ReconnectingMCPServerStdio, AsyncDebugMCPServerStdio, MCPNamespaceWrap, mcp_client_params, mcp_system_prompt, StreamableMCPThread, compress_name
2828
from render_utils import render_model_output, flush_async_output
2929
from env_utils import TmpEnv
3030
from yaml_parser import YamlParser
@@ -256,7 +256,7 @@ async def mcp_session_task(
256256
for handoff_agent in list(agents.keys())[1:]:
257257
handoffs.append(TaskAgent(
258258
# XXX: name has to be descriptive for an effective handoff
259-
name=handoff_agent,
259+
name=compress_name(handoff_agent),
260260
instructions=prompt_with_handoff_instructions(
261261
mcp_system_prompt(
262262
agents[handoff_agent]['personality'],
@@ -400,7 +400,7 @@ async def on_handoff_hook(
400400
if p:
401401
personality = available_tools.personalities.get(p)
402402
if personality is None:
403-
raise ValueError("No such personality!")
403+
raise ValueError(f"No such personality: {p}")
404404

405405
await deploy_task_agents(
406406
available_tools,
@@ -414,7 +414,7 @@ async def on_handoff_hook(
414414

415415
taskflow = available_tools.taskflows.get(t)
416416
if taskflow is None:
417-
raise ValueError("No such taskflow!")
417+
raise ValueError(f"No such taskflow: {t}")
418418

419419
await render_model_output(f"** 🤖💪 Running Task Flow: {t}\n")
420420

mcp_utils.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import os
1010
import socket
1111
import signal
12+
import hashlib
1213
from urllib.parse import urlparse
1314

1415
from mcp.types import CallToolResult, TextContent
@@ -18,6 +19,16 @@
1819

1920
DEFAULT_MCP_CLIENT_SESSION_TIMEOUT = 120
2021

22+
# The openai API complains if the name of a tool is longer than 64
23+
# chars. But we're encouraging people to use long descriptive
24+
# filekeys to avoid accidental collisions, so it's very easy to go
25+
# over the limit. So this function converts a name to a 12 character
26+
# hash.
27+
def compress_name(name):
28+
m = hashlib.sha256()
29+
m.update(name.encode('utf-8'))
30+
return m.hexdigest()[:12]
31+
2132
# A process management class for running in-process MCP streamable servers
2233
class StreamableMCPThread(Thread):
2334
"""Process management for local streamable MCP servers"""
@@ -221,7 +232,7 @@ class MCPNamespaceWrap:
221232
def __init__(self, confirms, obj):
222233
self.confirms = confirms
223234
self._obj = obj
224-
self.namespace = f"{obj.name.upper().replace(' ', '_').replace('/','-')}_"
235+
self.namespace = compress_name(obj.name)
225236

226237
def __getattr__(self, name):
227238
attr = getattr(self._obj, name)

personalities/assistant.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
seclab-taskflow-agent:
22
version: 1
33
filetype: personality
4-
filekey: personalities/assistant.yaml
4+
filekey: GitHubSecurityLab/seclab-taskflow-agent/personalities/assistant
55

66
personality: |
77
You are a helpful assistant.

personalities/c_auditer.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
seclab-taskflow-agent:
22
version: 1
33
filetype: personality
4-
filekey: personalities/c_auditer.yaml
4+
filekey: GitHubSecurityLab/seclab-taskflow-agent/personalities/c_auditer
55

66
personality: |
77
Your name is Ronald. You are a C programming language security expert.
@@ -15,5 +15,5 @@ task: |
1515
your findings where possible.
1616
1717
toolboxes:
18-
- toolboxes/memcache.yaml
19-
- toolboxes/codeql.yaml
18+
- GitHubSecurityLab/seclab-taskflow-agent/toolboxes/memcache
19+
- GitHubSecurityLab/seclab-taskflow-agent/toolboxes/codeql

personalities/examples/apple_expert.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
seclab-taskflow-agent:
22
version: 1
33
filetype: personality
4-
filekey: personalities/examples/apple_expert.yaml
4+
filekey: GitHubSecurityLab/seclab-taskflow-agent/personalities/examples/apple_expert
55

66
personality: |
77
You are an apples expert.

personalities/examples/banana_expert.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
seclab-taskflow-agent:
22
version: 1
33
filetype: personality
4-
filekey: personalities/examples/banana_expert.yaml
4+
filekey: GitHubSecurityLab/seclab-taskflow-agent/personalities/examples/banana_expert
55

66
personality: |
77
You are a bananas expert.

personalities/examples/echo.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
seclab-taskflow-agent:
22
version: 1
33
filetype: personality
4-
filekey: personalities/examples/echo.yaml
4+
filekey: GitHubSecurityLab/seclab-taskflow-agent/personalities/examples/echo
55

66
personality: |
77
You are a simple echo bot. You use echo tools to echo things.
@@ -10,5 +10,5 @@ task: |
1010
Echo user inputs using the echo tools.
1111
1212
toolboxes:
13-
- toolboxes/echo.yaml
13+
- GitHubSecurityLab/seclab-taskflow-agent/toolboxes/echo
1414

personalities/examples/example_triage_agent.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
seclab-taskflow-agent:
22
version: 1
33
filetype: personality
4-
filekey: personalities/examples/example_triage_agent.yaml
4+
filekey: GitHubSecurityLab/seclab-taskflow-agent/personalities/examples/example_triage_agent
55

66
personality: |
77
You are a triage agent. You route tasks to other agents.

personalities/examples/fruit_expert.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
seclab-taskflow-agent:
22
version: 1
33
filetype: personality
4-
filekey: personalities/examples/fruit_expert.yaml
4+
filekey: GitHubSecurityLab/seclab-taskflow-agent/personalities/examples/fruit_expert
55

66
personality: |
77
Your name is Bob. You are a fruit expert.

0 commit comments

Comments
 (0)