GitHub Security Lab Taskflow Agent
The Security Lab Taskflow Agent is an MCP-enabled multi-Agent framework for
declarative, YAML-driven agentic workflows.
Built on top of the OpenAI Agents SDK,
it uses Pydantic for grammar validation and
Jinja2 for template rendering.
Core Concepts
The Taskflow Agent leverages a GitHub Workflow-esque YAML based grammar to perform a series of tasks using a set of Agents.
Its primary value proposition is as a CLI tool that allows users to quickly define and script Agentic workflows without having to write any code.
Agents are defined through personalities, that receive a task to complete, given a set of tools.
Agents can cooperate to complete sequences of tasks through so-called taskflows.
You can find a detailed overview of the taskflow grammar here and example taskflows here.
Architecture
┌─────────────────────────────────────────────────────┐
│ CLI (cli.py) │
│ Typer-based entry point: -p, -t, -l, -g, -m, --resume, --lint│
└─────────────────────┬───────────────────────────────┘
│
┌─────────────────────▼───────────────────────────────┐
│ Runner (runner.py) │
│ Taskflow execution loop, model resolution, │
│ template rendering, session checkpointing │
└─────────────────────┬───────────────────────────────┘
│
┌─────────────────────▼───────────────────────────────┐
│ MCP Lifecycle (mcp_lifecycle.py) │
│ Server connection, cleanup, process management │
└─────────────────────┬───────────────────────────────┘
│
┌─────────────────────▼───────────────────────────────┐
│ Agent (agent.py) │
│ TaskAgent wrapper, hooks, OpenAI Agents SDK bridge │
└─────────────────────────────────────────────────────┘
Supporting modules:
models.py — Pydantic v2 grammar models (validation)
session.py — Task-level checkpoint / resume
available_tools.py — YAML resource loader with caching
template_utils.py — Jinja2 template environment
mcp_utils.py — MCP client parameter resolution
mcp_transport.py — MCP transport implementations (stdio, streamable)
mcp_prompt.py — System prompt construction
prompt_parser.py — Legacy prompt argument parser
capi.py — AI API endpoint and token management
path_utils.py — Platform-aware data/log directories
API Types
The agent supports both the Chat Completions and Responses OpenAI APIs.
The API type can be configured globally or per model in a model_config file:
seclab-taskflow-agent:
version: "1.0"
filetype: model_config
api_type: chat_completions # default for all models
models:
gpt_default: gpt-4.1
gpt_responses: gpt-5.1
model_settings:
gpt_responses:
api_type: responses # override for this model
endpoint: https://api.githubcopilot.com
token: CAPI_TOKEN # env var name containing the API key
Per-model model_settings can include:
api_type — "chat_completions" (default) or "responses"
endpoint — API base URL override for this model
token — name of an environment variable containing the API key
Backends
The runner can drive three SDKs behind a common interface:
openai_agents (default) — the OpenAI Agents Python SDK. Supports
multi-personality handoffs, both chat_completions and responses
api_type, temperature, parallel_tool_calls,
exclude_from_context, and MCP over stdio, SSE, and streamable HTTP.
copilot_sdk — the GitHub Copilot Python SDK. Supports streaming,
reasoning_effort, MCP over stdio/SSE/HTTP, and per-tool permission
gating. The SDK selects its own wire protocol per model, so the YAML
api_type field is not honoured; multi-personality handoffs,
temperature, and parallel_tool_calls are likewise not available.
Taskflows that use unsupported fields fail at load time with a
BackendCapabilityError naming the offending field.
anthropic_sdk — the Anthropic Python SDK, driving the native
Messages API (/v1/messages). Supports streaming, tool calling via
MCP, and adaptive thinking with configurable reasoning.effort
(low, medium, high, max). Handoffs are not supported.
Designed for use with CAPI's Anthropic endpoint; auth uses
Authorization: Bearer (not x-api-key).
Selection precedence (highest to lowest):
- Per-task
backend: in the task's own model_settings block (overrides
the model-level value for that one task; see _resolve_task_model()).
- Per-model
backend: in the model config's model_settings (allows
mixed backends in a single taskflow).
backend: field at the top level of the model config document
(global default).
SECLAB_TASKFLOW_BACKEND environment variable.
openai_agents.
seclab-taskflow-agent:
version: "1.0"
filetype: model_config
models:
code_analysis: claude-opus-4.7
general_tasks: gpt-5.4-mini
model_settings:
code_analysis:
api_type: messages
backend: anthropic_sdk
reasoning:
effort: high
general_tasks:
api_type: responses
backend: openai_agents
Error Translation and Retry
Each backend adapter translates its SDK-native exceptions into the neutral
hierarchy in sdk/errors.py, so the runner applies retry policy without
importing any SDK. Adding a backend means translating its errors too;
test_every_backend_adapter_translates_transport_failures enforces this
across the registry.
Transport failures need explicit handling and are easy to miss. The vendor
SDKs wrap httpx only around the call that sends the request, and with
streaming that returns once the response headers arrive while the body is
iterated afterwards. A connection that dies mid-body therefore surfaces as a
bare httpx error, in neither the SDK's own hierarchy nor the builtins'.
sdk/_transport.py enumerates the retriable ones, and each adapter maps them
to BackendTransportError. The set is enumerated rather than catching
httpx.TransportError wholesale, because LocalProtocolError means the
request was malformed and UnsupportedProtocol is deterministic.
Retry has a single owner: the branch, in _deploy_with_transport_retry. It is
the only level that resets capture state between attempts, so a tool result
recorded before a failure cannot be published twice or become the task's named
output, and it replays only the branch that failed rather than siblings that
may already have written to external systems. Retries are bounded by
TASK_RETRY_LIMIT with linear backoff from TASK_RETRY_BACKOFF.
Nothing above or below that retries the same classes. Retry loops nest, so a
class caught at two levels multiplies attempts rather than adding them, and
each attempt replays the whole conversation. drive_backend_stream retries
only BackendRateLimitError, where no content has been emitted yet, and takes
a reset_capture callback so even that path cannot leave a partial attempt's
results behind.
Deterministic failures are not retried at all. BackendMaxTurnsError,
BackendBadRequestError and BackendCapabilityError would repeat the same
failure with backoff, so deploy_task_agents reports them and returns.
Session Recovery
Taskflow runs are automatically checkpointed at the task level. If a task
fails after exhausting retries, the session is saved and can be resumed:
** 🤖💾 Session saved: abc123def456
** 🤖💡 Resume with: --resume abc123def456
Resume from the last successful checkpoint:
python -m seclab_taskflow_agent --resume abc123def456
The session checkpoint persists the CLI-provided --model-config value (if
any), so resumes use the same model configuration by default. To override the
model config on resume, pass --model-config / -m explicitly:
python -m seclab_taskflow_agent --resume abc123def456 -m examples.model_configs.responses_api
Failed tasks are automatically retried up to 3 times with increasing backoff
before the session is saved. Session checkpoints are stored in the
platform-specific application data directory.
Run Manifest
Every run produces a machine-readable manifest summarising what happened:
per-task status (ok / failed / skipped), the models each task ran against,
timing, and the named outputs each task produced (including per-model fan-in
records for multi-model tasks). It contains no endpoints or tokens.
The manifest is written to a run-scoped artifacts directory when a run finishes
or fails, and can be printed for any session by ID:
python -m seclab_taskflow_agent --manifest abc123def456
Error Output
By default, errors are shown as concise one-line messages. Use --debug (or
set TASK_AGENT_DEBUG=1) for full tracebacks:
# Concise (default)
Error: [BadRequestError] model 'foo' not found
(use --debug for full traceback)
# Full traceback
python -m seclab_taskflow_agent --debug -t examples.taskflows.echo
Linting and Schema
Taskflows can be validated offline, without making any model calls, using
--lint. This resolves the taskflow and every document it references
(personalities, toolboxes, model configs, reusable taskflows), checks model
names against the model config, validates prompt/over template syntax, and
reports unknown fields (likely typos):
# Validate a taskflow and its references
python -m seclab_taskflow_agent --lint -t examples.taskflows.echo
# Treat unknown fields as errors (not just warnings)
python -m seclab_taskflow_agent --lint --strict -t examples.taskflows.echo
--lint exits non-zero if any errors are found, so it can gate CI. The JSON
Schema for each grammar document type can be printed with --schema for editor
integration and external validation:
python -m seclab_taskflow_agent --schema
MCP Environment Denylist
By default, MCP server subprocesses inherit the parent environment. To prevent
specific variables from leaking to MCP servers, set TASKFLOW_ENV_DENYLIST to
a comma-separated list of variable names:
export TASKFLOW_ENV_DENYLIST="MY_SECRET_TOKEN,PRIVATE_KEY,OTHER_CREDENTIAL"
Toolbox-level env: declarations in YAML still inject exactly what each server
needs, so explicitly configured variables are unaffected.
Use Cases and Examples
The Seclab Taskflow Agent framework was primarily designed to fit the iterative feedback loop driven work involved in Agentic security research workflows and vulnerability triage tasks.
Its design philosophy is centered around the belief that a prompt level focus of capturing vulnerability patterns will greatly improve and scale security research results as frontier model capabilities evolve over time.
At GitHub Security Lab, we primarily use this framework as a code auditing tool, but it can also serve as a more generic swiss army knife for exploring Agentic workflows. For example, we also use this framework for automated code scanning alert triage.
The framework includes a CodeQL MCP server that can be used for Agentic code review, see the CVE-2023-2283 taskflow for an example of how to have an Agent review C code using a CodeQL database (demo video).
Instead of generating CodeQL queries itself, the CodeQL MCP Server is used to provide CodeQL-query based MCP tools that allow an Agent to navigate and explore code. It leverages templated CodeQL queries to provide targeted context for model driven code analysis.
Model comparison and evaluation
The framework can also run the same prompt across several models and compare their answers, which is useful for evaluating models against each other on a given task. The example_model_comparison taskflow shows the pattern: a multi-model task fans the same question out across two models, captures each model's prose answer with capture: response, and a second "judge" task reads every captured answer by name (outputs.answers) and picks the best one.
Run it against your endpoint like any other taskflow:
python -m seclab_taskflow_agent -t examples.taskflows.example_model_comparison
Each model answers in its own labelled output block, and the judge task then compares them, for example:
** 🤖✏️ Output for gpt_alt
A use-after-free bug is a type of software vulnerability that occurs when a program continues to use a memory location after it has been freed ...
** 🤖✏️ Output for gpt_fast
A use-after-free bug occurs when a program continues to use memory after it has been freed ...
The gpt_fast answer is best because it is more concise while still clearly explaining ...