Skip to content

Commit f6f4207

Browse files
committed
Merge branch 'feat/refactor-agents-base' of github.com:cloudflare/orange-builds into feat/refactor-agents-base
2 parents f3ab5f5 + 4939429 commit f6f4207

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

worker/agents/core/behaviors/agentic.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,14 @@ export class AgenticCodingBehavior extends BaseCodingBehavior<AgenticState> impl
227227
}
228228

229229
getOperationOptions(): OperationOptions<AgenticGenerationContext> {
230+
const context = GenerationContext.from(this.state, this.getTemplateDetails(), this.logger);
231+
if (!GenerationContext.isAgentic(context)) {
232+
throw new Error('Expected AgenticGenerationContext');
233+
}
230234
return {
231235
env: this.env,
232236
agentId: this.getAgentId(),
233-
context: GenerationContext.from(this.state, this.getTemplateDetails(), this.logger) as AgenticGenerationContext,
237+
context,
234238
logger: this.logger,
235239
inferenceContext: this.getInferenceContext(),
236240
agent: this

worker/agents/core/behaviors/phasic.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,14 @@ export class PhasicCodingBehavior extends BaseCodingBehavior<PhasicState> implem
199199
}
200200

201201
getOperationOptions(): OperationOptions<PhasicGenerationContext> {
202+
const context = GenerationContext.from(this.state, this.getTemplateDetails(), this.logger);
203+
if (!GenerationContext.isPhasic(context)) {
204+
throw new Error('Expected PhasicGenerationContext');
205+
}
202206
return {
203207
env: this.env,
204208
agentId: this.getAgentId(),
205-
context: GenerationContext.from(this.state, this.getTemplateDetails(), this.logger) as PhasicGenerationContext,
209+
context,
206210
logger: this.logger,
207211
inferenceContext: this.getInferenceContext(),
208212
agent: this

worker/agents/core/stateMigration.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,14 @@ export class StateMigration {
233233
if (hasTemplateDetails) {
234234
delete stateWithDeprecated.templateDetails;
235235
}
236+
let migratedBehaviorType = state.behaviorType;
236237
if (isStateWithAgentMode(state)) {
237-
delete stateWithDeprecated.agentMode;
238+
migratedBehaviorType = state.agentMode === 'smart' ? 'agentic' : 'phasic';
239+
needsMigration = true;
240+
logger.info('Migrating agentMode to behaviorType', {
241+
oldMode: state.agentMode,
242+
newType: migratedBehaviorType
243+
});
238244
}
239245

240246
return newState;

worker/agents/operations/AgenticProjectBuilder.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ export class AgenticProjectBuilderOperation extends AgentOperationWithTools<
152152

153153
const hasFiles = (filesIndex || []).length > 0;
154154
const isAgenticBlueprint = (bp?: Blueprint): bp is AgenticBlueprint => {
155-
return !!bp && Array.isArray((bp as any).plan);
155+
if (!bp) return false;
156+
return 'plan' in bp && Array.isArray(bp.plan);
156157
};
157158
const hasTSX = filesIndex?.some(f => /\.(t|j)sx$/i.test(f.filePath)) || false;
158159
const hasMD = filesIndex?.some(f => /\.(md|mdx)$/i.test(f.filePath)) || false;

0 commit comments

Comments
 (0)