Skip to content

Commit 7b70ce2

Browse files
V48 (specification-implementation): Extract PTRR base Agent into generic-agents/PTRR
Mirror the SDIVF pipeline extraction for Agents: - @bitcode/agent-generics keeps Agent primitives (factoryAgent, QuickAgent, steps, substeps) - @bitcode/generic-agents-ptrr owns PTRRAgent assembly (factoryPTRRAgent / BC factoryAgentWithPTRR) - Lazy requires avoid agent-generics ↔ PTRR BC re-export load cycles under ts-jest - Hierarchy docs updated (FAMILIARIZATION, SOURCE_LAYOUT, V48 NOTES)
1 parent 950b217 commit 7b70ce2

24 files changed

Lines changed: 762 additions & 669 deletions

BITCODE_SPEC_V48_NOTES.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1618,6 +1618,17 @@ not provider packages.
16181618
HostKind `local` replaces `inline` (BITCODE_PIPELINE_HOST; `inline` accepted as alias).
16191619
Spec G3-4 tables updated to LocalHost / hostKind `local`.
16201620

1621+
## PTRR base Agent extraction (Garrett, 2026-07-13)
1622+
1623+
```
1624+
@bitcode/agent-generics # Agent primitive (factoryAgent, QuickAgent, substeps)
1625+
→ @bitcode/generic-agents-ptrr # packages/generic-agents/PTRR (PTRRAgent base)
1626+
```
1627+
1628+
Preferred hierarchy names: `PTRRAgent`, `factoryPTRRAgent`.
1629+
BC: `factoryAgentWithPTRR` / `factoryAgentWithPTRRGenerations` re-exported from agent-generics.
1630+
Mirrors SDIVF extraction: pipelines-generics → generic-pipelines/SDIVF.
1631+
16211632
## MCP hierarchy modularization (Garrett, 2026-07-13)
16221633

16231634
```

FAMILIARIZATION.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,15 +147,18 @@ Hierarchy names: `Measurement` → `AbsolutesMeasureAgent` →
147147
@bitcode/generic-generations-failsafes failsafes/ — prepared-context types + base
148148
@bitcode/generic-generations-thinkings thinkings/ — Reason→Judge→StructuredOutput base
149149
150-
@bitcode/agent-generics composes failsafes/thinkings into PTRR Agents
150+
@bitcode/agent-generics Agent primitive (factoryAgent, factoryQuickAgent, substeps)
151151
152-
@bitcode/pipeline-asset-pack product synthesis / phase agents (no reimplementation)
152+
@bitcode/generic-agents-ptrr PTRRAgent base (Plan→Try→Refine→Retry)
153+
154+
@bitcode/generic-agent-* / product agents specialized prompts/tools (no PTRR reimplementation)
153155
```
154156

155-
Package path: `packages/generic-generations/{failsafes,thinkings}/`.
157+
Package paths: `packages/generic-generations/{failsafes,thinkings}/`,
158+
`packages/generic-agents/PTRR/`.
156159

157-
**PTRR** (Plan / Try / Refine / Retry) is the agent step model. Each step runs a
158-
**Failsafes** sequence:
160+
**PTRR** (Plan / Try / Refine / Retry) is the base Agent step model
161+
(`@bitcode/generic-agents-ptrr`). Each step runs a **Failsafes** sequence:
159162

160163
1. **PrepareConciseContext** — select execution-state *keys* (not values)
161164
2. **ChunkThenSum** — task generation; chunk only if request too large
@@ -171,7 +174,11 @@ context domain. `@bitcode/context` retains only process-global `GlobalContext`
171174
LLM-bound failsafe/thinkings **factories** still execute via `AgentExecution`
172175
inside `agent-generics` until inverted onto pure Execution + LLM registry.
173176

174-
Factories: `factoryAgent`, `factoryAgentWithPTRR` in `agent-generics`.
177+
| Layer | Type name | Factory |
178+
| --- | --- | --- |
179+
| Primitive | `Agent` | `factoryAgent`, `factoryQuickAgent` |
180+
| Base + primitive | `PTRRAgent` | `factoryPTRRAgent` (`factoryAgentWithPTRR` BC) |
181+
| Specific | product agents | specialized configs over `factoryPTRRAgent` |
175182

176183
### 3.2.0 VCS
177184

internal-docs/BITCODE_SOURCE_LAYOUT.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ packages/generic-<family>/ # README only (no package.json)
204204

205205
| Family | Nested examples | Package names |
206206
| --- | --- | --- |
207-
| `generic-agents/` | `vcs/`, `danger-wall/`, … | `@bitcode/generic-agents-*` |
207+
| `generic-agents/` | `PTRR/`, `vcs/`, `danger-wall/`, … | `@bitcode/generic-agents-ptrr`, `@bitcode/generic-agent-*` |
208208
| `generic-tools/` | `web-search/`, `vcs/`, … | `@bitcode/generic-tools-*` |
209209
| `generic-pipelines/` | `SDIVF/` | `@bitcode/generic-pipelines-sdivf` (`SDIVFPipeline`) |
210210
| `generic-llms/` | `xAI/`, `OpenAI/`, `Anthropic/`, `Google/`, `defaults/`, `registry/` | `@bitcode/generic-llms-*` (+ aggregator `@bitcode/generic-llms`) |

packages/agent-generics/README.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,24 @@
11
# Agent Generics
22

3-
Agents execute decisions through PTRR methodology with hierarchical prompt accumulation using typed Generations.
3+
Agent **primitives**: execution, registries, substeps, `factoryAgent` / `factoryQuickAgent`.
4+
5+
## Hierarchy
6+
7+
```
8+
@bitcode/agent-generics # this package (Agent primitive)
9+
10+
@bitcode/generic-agents-ptrr # PTRRAgent base (Plan→Try→Refine→Retry)
11+
12+
product / generic-agent-* # specialized agents
13+
```
14+
15+
PTRR base factories (`factoryPTRRAgent` / BC `factoryAgentWithPTRR`) live in
16+
`@bitcode/generic-agents-ptrr` and are re-exported here for compatibility.
417

518
## Quick vs. PTRR Agents
619

7-
- Agent (PTRR): Canonical, sequences Plan → Try → Refine → Retry. Each generation uses the 3×3 failsafed generation pattern by default.
8-
- QuickAgent: Minimal, single‑generation agent for setup/utility behaviors where PTRR is unnecessary. Uses standard Execution state and registry access.
20+
- **PTRRAgent** (`@bitcode/generic-agents-ptrr`): sequences Plan → Try → Refine → Retry. Each generation uses the 3×3 failsafed generation pattern by default.
21+
- **QuickAgent** (this package): Minimal, single‑generation agent for setup/utility behaviors where PTRR is unnecessary.
922

1023
Create a QuickAgent:
1124

packages/agent-generics/jest.config.cjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ module.exports = {
1919
'^@bitcode/asset-packs-settle$': '<rootDir>/../asset-packs/settle/src/index.ts',
2020
'^@bitcode/agent-generics/agents/factories$': '<rootDir>/../agent-generics/src/agents/factories.ts',
2121
'^@bitcode/agent-generics/types$': '<rootDir>/../agent-generics/src/types.ts',
22+
'^@bitcode/generic-agents-ptrr$': '<rootDir>/../generic-agents/PTRR/src/index.ts',
23+
'^@bitcode/generic-agents-ptrr/(.*)$': '<rootDir>/../generic-agents/PTRR/src/$1',
2224
'^@bitcode/generic-llms$': '<rootDir>/../generic-llms/registry/src/index.ts',
2325
'^@bitcode/generic-llms/defaults$': '<rootDir>/../generic-llms/defaults/src/index.ts',
2426
'^@bitcode/generic-llms-defaults$': '<rootDir>/../generic-llms/defaults/src/index.ts',

packages/agent-generics/package.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"@bitcode/generation-generics": "workspace:*",
1717
"@bitcode/generic-generations-failsafes": "workspace:*",
1818
"@bitcode/generic-generations-thinkings": "workspace:*",
19+
"@bitcode/generic-agents-ptrr": "workspace:*",
1920
"@bitcode/generic-llms": "workspace:*",
2021
"@bitcode/prompts": "workspace:*",
2122
"@bitcode/tools-generics": "workspace:*",
@@ -37,6 +38,13 @@
3738
"exports": {
3839
".": "./src/index.ts",
3940
"./agents/factories": "./src/agents/factories.ts",
40-
"./types": "./src/types.ts"
41+
"./types": "./src/types.ts",
42+
"./execution": "./src/execution/index.ts",
43+
"./substeps/factories": "./src/substeps/factories.ts",
44+
"./diagnostics/instrumentation": "./src/diagnostics/instrumentation.ts",
45+
"./steps/failsafe-sequence": "./src/steps/failsafe-sequence.ts",
46+
"./steps/factories": "./src/steps/factories.ts",
47+
"./steps/step-schemas": "./src/steps/step-schemas.ts",
48+
"./steps/*": "./src/steps/*"
4149
}
4250
}

packages/agent-generics/src/__tests__/factory-agent-ptrr-prompt-hierarchy.test.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// @ts-nocheck
22
import { z } from 'zod';
3-
import { factoryAgentWithPTRR } from '../agents/factories';
3+
import { factoryAgentWithPTRR } from '@bitcode/generic-agents-ptrr';
44

55
const OutputSchema = z.object({
66
ok: z.boolean()
@@ -38,34 +38,34 @@ describe('factoryAgentWithPTRR Bitcode prompt hierarchy', () => {
3838
prompt: promptRegistry('system'),
3939
stepPrompts: {
4040
plan: () => promptRegistry('plan')
41-
}
42-
} as any)
43-
).toThrow(/missing try, refine, retry step Prompt registries/u);
41+
} as any
42+
})
43+
).toThrow(/missing try, refine, retry/u);
4444
});
4545

46-
it('accepts the explicit prompt plus stepPrompts carrier', () => {
46+
it('accepts primary prompt + stepPrompts carrier', () => {
4747
const agent = factoryAgentWithPTRR({
48-
name: 'complete-explicit-prompt-carrier',
48+
name: 'primary-carrier',
4949
outputSchema: OutputSchema,
5050
prompt: promptRegistry('system'),
5151
stepPrompts: stepPromptRegistry(),
52-
enforceLLM: false
52+
enforceLLM: false,
5353
});
54-
54+
expect(agent.name).toBe('primary-carrier');
5555
expect(agent.steps).toHaveLength(4);
5656
});
5757

58-
it('accepts the compact prompts carrier with system plus complete PTRR steps', () => {
58+
it('accepts compact prompts.system + plan/try/refine/retry carrier', () => {
5959
const agent = factoryAgentWithPTRR({
60-
name: 'complete-compact-prompt-carrier',
60+
name: 'compact-carrier',
6161
outputSchema: OutputSchema,
6262
prompts: {
6363
system: promptRegistry('system'),
6464
...stepPromptRegistry()
6565
},
66-
enforceLLM: false
66+
enforceLLM: false,
6767
});
68-
68+
expect(agent.name).toBe('compact-carrier');
6969
expect(agent.steps).toHaveLength(4);
7070
});
7171
});

packages/agent-generics/src/__tests__/ptrr-step-schemas.test.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,17 @@ jest.mock('../steps/factories', () => {
1818
factoryRetryStep: step('retry'),
1919
};
2020
});
21+
jest.mock('@bitcode/agent-generics/steps/factories', () => {
22+
const step = (type: string) => jest.fn(() => Object.assign(async (input: any) => input, { type }));
23+
return {
24+
factoryPlanStep: step('plan'),
25+
factoryTryStep: step('try'),
26+
factoryRefineStep: step('refine'),
27+
factoryRetryStep: step('retry'),
28+
};
29+
});
2130

22-
import { factoryAgentWithPTRR } from '../agents/factories';
31+
import { factoryAgentWithPTRR } from '@bitcode/generic-agents-ptrr';
2332
import { factoryPlanStep, factoryTryStep, factoryRefineStep, factoryRetryStep } from '../steps/factories';
2433
import { PlanStepOutputSchema } from '../steps/step-schemas';
2534

packages/agent-generics/src/agents/factories.d.ts

Lines changed: 0 additions & 138 deletions
This file was deleted.

0 commit comments

Comments
 (0)