DocsQuick StartAI News
AI NewsTrellis Supports Codex Hook and Sub-Agents, Bringing the AI Programming Framework into the Orchestration Era
Industry News

Trellis Supports Codex Hook and Sub-Agents, Bringing the AI Programming Framework into the Orchestration Era

2026-04-10
Trellis Supports Codex Hook and Sub-Agents, Bringing the AI Programming Framework into the Orchestration Era

Trellis has recently been updated to support Codex’s Hook and Sub-Agent mechanisms, enabling the AI coding agent to have session-level lifecycle management and multi-agent orchestration capabilities, though issues with context usage still need optimization.

Trellis recently rolled out an update worth paying attention to: it now officially supports Codex’s Hook and Sub-Agent mechanisms.

This isn’t a small feature iteration. It means Trellis has taken a step from being a “scaffolding tool that helps you manage specs and workflows” toward becoming an “AI agent orchestration layer.” For developers using terminal AI coding tools like Codex or Claude Code, this change has a direct impact on your daily workflow.

Let’s start with what the Hook mechanism actually does

The essence of Trellis’s Hook mechanism is adding lifecycle hooks to AI programming sessions. The core one is the Session Start Hook — each time you start a Codex session, Trellis automatically runs an initialization routine:

  1. Reads workflow.md to inject project development conventions and processes into context
  2. Runs get-context.py to pull the current developer identity, Git state, active tasks, and historical conversation metadata
  3. Reads the spec index so the AI knows what specification documents are available for the project
  4. Reports the context to the developer, then asks, “What would you like to work on?”

It sounds simple, but it solves a real pain point: every time you start a new session, you no longer have to spend 5 minutes manually feeding the AI background info. Trellis’s start.md funnels the entire development session into its standard single-process serialized path — only one agent runs at a time, avoiding multiple AI agents stepping on each other.

The design idea is clear: context management in AI programming tools shouldn’t be a developer’s burden.

Diagram showing Trellis Session Start Hook execution process, from session start to context injection

Sub-Agent: teaching AI agents to “divide the work”

Even more interesting than Hooks is the Sub-Agent mechanism.

Traditional AI programming sessions are single-threaded — you give an instruction, the AI executes it, and only then do you send the next one. With Sub-Agents, the main agent can spawn child agents to handle specific subtasks while it continues the main thread.

For example: previously, if you asked the AI to refactor a module, it had to analyze the code, modify logic, run tests, and fix lint errors all sequentially. With Sub-Agents, the main agent can offload relatively independent tasks like “run tests and fix failing cases” to a sub-agent, then move on to the next file itself.

In Trellis’s implementation, Sub-Agents and Hooks work together. The Session Start Hook establishes the baseline context, and the Sub-Agent executes concrete tasks on that baseline. Both task.py and add_session.py already support the --package parameter, meaning that in a monorepo scenario, sub-agents can be constrained to a specific package’s scope and not cross boundaries.

That’s a real improvement for large projects. Imagine a monorepo with 20 packages, and you only want to modify things in packages/cli. A Sub-Agent can load only the specs under spec/cli/backend/ instead of stuffing the entire repository’s specs into the context window.

Context occupation: the elephant in the room

But things aren’t all rosy.

Developers in the community have already raised a very practical issue: the Session Start Hook uses up around 10% of the context after execution. That doesn’t sound like much, but if you’re running a large project, loading workflow.md and start.md can take up 40K–80K tokens of context space.

Keep in mind that Codex has a hard context window limit. If the framework itself consumes 40K–80K tokens, that leaves much less room for actual coding tasks. Some developers have pointed out directly: workflow.md and start.md contain a lot of repetitive explanations — can they be streamlined?

This issue isn’t unique to Trellis. Any framework that tries to add “memory” and “rules” to AI programming faces the same tradeoff: the more context you inject, the more the AI understands your project; but context windows are limited, and stuffing too much framework information leaves little room for real code.

For now, the Trellis team hasn’t proposed a clear optimization plan. It’s an area that needs ongoing attention — if the context footprint isn’t addressed, the practicality of the Hook mechanism in large projects will be compromised.

Monorepo support: more than just directory structure

Another aspect worth elaborating on in this update is Trellis’s enhanced monorepo support.

trellis init now automatically detects pnpm, npm, Cargo, Go, uv workspaces, and git submodules. Once a monorepo structure is detected, it no longer generates single .trellis/spec/frontend and .trellis/spec/backend directories, but creates independent spec directories for each package.

# Initialize a monorepo project
trellis init

# If the automatic detection is inaccurate, you can force it
trellis init --monorepo

# You can also pull spec templates from a custom registry
trellis init --registry https://github.com/your-org/your-spec-templates -t my-stack

The generated directory structure looks roughly like this:

.trellis/
├── config.yaml
├── workflow.md
├── scripts/
│   └── get-context.py
├── spec/
│   ├── cli/
│   │   ├── frontend/
│   │   ├── backend/
│   │   └── guides/
│   ├── web-app/
│   │   ├── frontend/
│   │   ├── backend/
│   │   └── guides/
│   └── shared-lib/
│       └── ...
└── workspace/
    └── index.md

The key lies in spec_scope filtering. The Session Start Hook supports loading specs by scope, and task.py supports the --package parameter. This means that when the AI processes tasks for the cli package, it only reads documentation under spec/cli/, unaffected by other packages’ information.

For teams managing large monorepos, this design directly solves the problem of “AI context polluted by unrelated information.”

Multi-platform integration: not just Codex

Trellis’s ambitions extend beyond Codex. From the files it generates during initialization, it’s clear that it supports multiple AI coding platforms:

  • .claude/ — Claude Code
  • .cursor/ — Cursor
  • .kiro/ — Kiro
  • .agents/ — Generic agent configuration
  • AGENTS.md — Project-level agent documentation

This shows that Trellis aims to become a cross-platform AI programming workflow management layer. You define your project specs, development workflow, and task management once, and regardless of whether team members use Codex, Cursor, or Claude Code, they all share the same context.

It’s a smart positioning. The competition among AI programming tools is far from settled, and developers don’t want to be locked into one tool. Trellis positions itself above the tool layer, focusing on “standardizing conventions and workflows” — regardless of which AI is running underneath, the workflow on top stays consistent.

What it means for developers

Back to real-world impact.

The Hook + Sub-Agent combo is essentially answering one question: what should the “operating system” for AI programming agents look like?

Current AI coding tools — whether Codex, Cursor, or Claude Code — are still in the “single-task, stateless” phase. Each new session starts blank, and developers have to re-provide background info. Trellis’s Hook mechanism tries to solve the “stateless” problem, while Sub-Agent addresses the “single-task” limitation.

The direction is right, but maturity is lacking. The context consumption issue shows that framework overhead still needs optimization, and Sub-Agent’s scheduling strategy remains early-stage. Some developers are asking for a “stable release,” suggesting there are still edge cases uncovered in production.

If your project already uses Codex for daily development, this Trellis update is worth trying — especially for monorepo scenarios where spec isolation and package-level task distribution via Sub-Agents can truly reduce context pollution. But if your project is small, the context overhead introduced by Hooks might outweigh the benefits.

Relation to API calls

For developers building their own coding toolchains via API calls to large models, Trellis’s mechanisms provide a reference architecture. You can implement a similar Hook logic in your own tools — before each API call, automatically inject project context:

import openai

client = openai.OpenAI(
    api_key="your-api-key",
    base_url="https://api.openai-hub.com/v1"  # OpenAI Hub supports GPT/Claude/Gemini/DeepSeek and other mainstream models
)

# Simulate Trellis's Session Start Hook: inject project context
def build_session_context(project_path, package=None):
    """Read project specs and construct session context"""
    context_parts = []
    
    # Read workflow rules
    with open(f"{project_path}/.trellis/workflow.md") as f:
        context_parts.append(f"## Project Workflow\n{f.read()}")
    
    # Monorepo scenario: load only the specified package’s specs
    if package:
        spec_path = f"{project_path}/.trellis/spec/{package}"
    else:
        spec_path = f"{project_path}/.trellis/spec"
    
    # ... Load spec files
    return "\n\n".join(context_parts)


session_context = build_session_context("./my-project", package="cli")

response = client.chat.completions.create(
    model="claude-sonnet-4-20250514",  # Use OpenAI Hub to call Claude
    messages=[
        {"role": "system", "content": session_context},
        {"role": "user", "content": "Refactor the CLI package’s command parsing module using clap v4’s derive API"}
    ]
)

print(response.choices[0].message.content)

The key idea is to extract Trellis’s Hook logic as a pre-processing step before API calls. That way, no matter which model you use, you still benefit from automatic context injection.

Final thoughts

AI coding tools are moving from “code completion” toward “project understanding.” Trellis’s Hook + Sub-Agent is a meaningful experiment in this trend, attempting to build a persistent, structured connection layer between AI and projects.

But the framework’s value ultimately depends on whether its overhead remains manageable. 40K–80K tokens of context use is quite heavy for what’s supposed to be a “support layer.” Hopefully the Trellis team will provide optimization options in future versions — such as on-demand spec loading, workflow compression, or moving part of the context to a retrieval layer instead of stuffing everything into the prompt.

The direction is sound; the execution still needs polish.


References:

Related Articles

View All

Contact Us

We usually reply quickly during business hours

Scan WeChat

Support: Hub Assistant

WeChat ID: