Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 26 additions & 25 deletions WORKFLOW.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,34 +201,38 @@ get_code_snippet(qualified_name="pkg/file.Function")
| Real Persistence | ❌ None |
| LLM Integration | ❌ None |

### Phase Progress

| Phase | Status | PR | CI |
| ------------------------------ | -------------- | ----------- | ------------ |
| Phase 0 — Foundation Cleanup | ✅ Done | Merged | ✅ |
| Phase 1 — Wire Components | ✅ Done | Merged | ✅ |
| Phase 2 — Real Persistence | ⏸️ **BLOCKED** | PR #30 OPEN | ❌ **GAGAL** |
| Phase 3 — Agent Implementation | ⏳ Pending | - | - |
| Phase 4 — Tool Integration | ⏳ Pending | - | - |
| Phase 5 — Cognitive Layer | ⏳ Pending | - | - |
| Phase 6 — API & Integration | ⏳ Pending | - | - |
| Phase 7 — Production Hardening | ⏳ Pending | - | - |
| Phase 8 — Documentation | ⏳ Pending | - | - |
### Phase Progress (Updated: July 23, 2026)

| Phase | Status | PR | CI |
| ------------------------------ | ------------------ | ------------- | ----------- |
| Phase 0 — Foundation Cleanup | ✅ Done | Merged | ✅ |
| Phase 1 — Wire Components | ✅ Done | Merged | ✅ |
| Phase 2 — Real Persistence | ✅ Done | PR #30 MERGED | |
| Phase 3 — Agent Implementation | ✅ Done | Merged | ✅ |
| Phase 4 — Tool Integration | ⏸️ **IN PROGRESS** | PR #36 OPEN | ✅ **PASS** |
| Phase 5 — Cognitive Layer | ⏳ Pending | - | - |
| Phase 6 — API & Integration | ⏳ Pending | - | - |
| Phase 7 — Production Hardening | ⏳ Pending | - | - |
| Phase 8 — Documentation | ⏳ Pending | - | - |

---

## 🚨 Current Blocker

```
Phase 2 (Batch 4) - PR #30 CI GAGAL
Phase 4 (Batch 2) - PR #36 CI PASS ✅
├─ Status: OPEN
├─ Branch: feat/phase-2-batch-4-runtime-migration
├─ CI Check: quality-gates → FAILURE
├─ Branch: feat/phase-4-batch-2-tool-timeout-enforcement
├─ CI Check: quality-gates → SUCCESS
└─ RULE: TIDAK LANJUT KE PHASE 3 SAMPAI PR #30 HIJAU
└─ Next: Merge PR #36, lanjut Phase 4 Batch 3 atau Phase 5
```

### History Blockers (Resolved)

- ~~Phase 2 (Batch 4) - PR #30 CI GAGAL~~ → **MERGED** ✅

---

## 📁 Reference Documents
Expand Down Expand Up @@ -286,15 +290,12 @@ Phase 2 (Batch 4) - PR #30 CI GAGAL

## 🚀 Next Action

**Prioritas #1:** Fix CI failure PR #30
**Prioritas #1:** Merge PR #36 (CI sudah hijau)

```
1. ✅ Fix issues (typecheck, lint, tests)
2. ✅ Local testing: pnpm typecheck, lint, build, test
3. ✅ Push update ke PR #30
4. ⏳ Tunggu CI hijau
5. Merge PR #30
6. BARU lanjut ke Phase 3
1. ✅ PR #36 CI hijau
2. ⏳ Merge PR #36
3. ⏳ Lanjut Phase 4 Batch 3 atau Phase 5
```

---
Expand Down Expand Up @@ -410,5 +411,5 @@ NODE_ENV="test"
---

**Document Owner:** Orchestrator
**Last Updated:** July 2026
**Last Updated:** July 23, 2026
**Next Review:** Setiap selesai batch
8 changes: 7 additions & 1 deletion packages/provider/provider-sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ export * from './metrics.js';
export * from './resilience.js';
export * from './base-provider.js';
export * from './registry.js';
export { ProviderFactory, HealthCheckService, CapabilityDiscovery, ProviderRegistryCache } from './factory.js';
export {
ProviderFactory,
HealthCheckService,
CapabilityDiscovery,
ProviderRegistryCache,
} from './factory.js';
export { CredentialResolver } from './conformance/credential-resolver.js';
export * from './conformance/index.js';
export type {
Expand All @@ -12,5 +17,6 @@ export type {
CompletionResponse,
NormalizedToolSpec,
NormalizedToolCall,
ToolResult,
Provider,
} from './interfaces.js';
1 change: 1 addition & 0 deletions packages/shared/tool-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"@agentx/cache": "workspace:*",
"@agentx/core-runtime": "workspace:*",
"@agentx/observability": "workspace:*",
"@agentx/provider-sdk": "workspace:*",
"yaml": "^2.9.0"
}
}
1 change: 1 addition & 0 deletions packages/shared/tool-sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ export * from './discovery/index.js';
export * from './pipeline/index.js';
export * from './shell/shell-sandbox.js';
export * from './approval/index.js';
export * from './orchestrator/index.js';
155 changes: 155 additions & 0 deletions packages/shared/tool-sdk/src/orchestrator/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
import type {
IToolRegistry,
ToolExecutionRequest,
ToolExecutionContext,
} from '../interfaces/index.js';
import type { ToolExecutionPipeline } from '../interfaces/index.js';
import type {
NormalizedToolSpec,
NormalizedToolCall,
ToolResult as ProviderToolResult,
CompletionResponse,
} from '@agentx/provider-sdk';

export interface ToolOrchestratorConfig {
maxIterations: number;
timeoutMs: number;
workingDirectory: string;
}

export interface OrchestrationResult {
finalText: string;
toolCalls: NormalizedToolCall[];
toolResults: ProviderToolResult[];
totalIterations: number;
success: boolean;
error?: string;
}

export class ToolOrchestrator {
private registry: IToolRegistry;
private pipeline: ToolExecutionPipeline;
private config: ToolOrchestratorConfig;

constructor(
registry: IToolRegistry,
pipeline: ToolExecutionPipeline,
config?: Partial<ToolOrchestratorConfig>,
) {
this.registry = registry;
this.pipeline = pipeline;
this.config = {
maxIterations: config?.maxIterations ?? 10,
timeoutMs: config?.timeoutMs ?? 60000,
workingDirectory: config?.workingDirectory ?? process.cwd(),
};
}

public async executeToolCalls(
toolCalls: NormalizedToolCall[],
context: ToolExecutionContext,
): Promise<ProviderToolResult[]> {
const results: ProviderToolResult[] = [];

for (const toolCall of toolCalls) {
const tool = this.registry.find(toolCall.toolName);
if (!tool) {
results.push({
callId: toolCall.callId,
output: '',
success: false,
error: `Tool '${toolCall.toolName}' not found`,
});
continue;
}

try {
const request: ToolExecutionRequest = {
toolName: toolCall.toolName,
category: tool.definition.category,
arguments: toolCall.arguments,
context,
};

const response = await this.pipeline.execute(request, tool);

results.push({
callId: toolCall.callId,
output: response.result.output,
success: response.result.success,
error: response.result.error,
});
} catch (error) {
results.push({
callId: toolCall.callId,
output: '',
success: false,
error: error instanceof Error ? error.message : String(error),
});
}
}

return results;
}

public async runWithToolLoop(
initialResponse: CompletionResponse,
context: ToolExecutionContext,
): Promise<OrchestrationResult> {
const allToolCalls: NormalizedToolCall[] = [];
const allToolResults: ProviderToolResult[] = [];
let iterations = 0;
const response = initialResponse;

while (response.toolCalls.length > 0 && iterations < this.config.maxIterations) {
iterations++;

allToolCalls.push(...response.toolCalls);

const toolResults = await this.executeToolCalls(response.toolCalls, context);
allToolResults.push(...toolResults);

if (toolResults.some((r) => !r.success)) {
const failedTools = toolResults.filter((r) => !r.success);
return {
finalText: response.text,
toolCalls: allToolCalls,
toolResults: allToolResults,
totalIterations: iterations,
success: false,
error: `Tool execution failed: ${failedTools.map((f) => f.error).join(', ')}`,
};
}

break;
}

if (iterations >= this.config.maxIterations) {
return {
finalText: response.text,
toolCalls: allToolCalls,
toolResults: allToolResults,
totalIterations: iterations,
success: false,
error: `Max iterations (${this.config.maxIterations}) reached`,
};
}

return {
finalText: response.text,
toolCalls: allToolCalls,
toolResults: allToolResults,
totalIterations: iterations,
success: true,
};
}

public static toolSpecsFromRegistry(registry: IToolRegistry): NormalizedToolSpec[] {
const tools = registry.list();
return tools.map((tool) => ({
name: tool.definition.name,
description: tool.definition.description,
parameters: tool.definition.parametersSchema,
}));
}
}
Loading
Loading