Skip to content

Conversation

devversion
Copy link
Member

  • Renames Gateway to Executor with strict validation via Zod.
  • Attaches executor specific configuration to the executor, instead of letting (previous) gateways extract information through multiple layer of indirections from the Environment.
    • This also resulted in lots of difficulties around generics and heritage.
  • No longer passes around gateway, or executors as they can be directly accessed from the Environment.
  • Adds a compatibility layer for old configs where the local executor is "assumed" and configured at the top-level environment config object.
  • Updates the remote environment example with the new API.
  • Improves the gateway/executor API to be better named and support async model validation, or destroying.


export type Environment = LocalEnvironment | RemoteEnvironment;
/** Represents a single prompt evaluation environment. */
export class Environment {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just moving back the previous base-environment.ts into the environment.ts file

localEnvironmentConfigSchema,
remoteEnvironmentConfigSchema,
]);
export const environmentConfigSchema = z.object({
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the same schema as from base-environment-config.ts

import {mcpServerOptionsSchema} from '../../codegen/llm-runner.js';
import {getPossiblePackageManagers} from '../../configuration/environment-config.js';

export const localExecutorConfigSchema = z.strictObject({
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the schema from environment-local.ts because it's now tied to the local executor directly.

@@ -0,0 +1,204 @@
import {ChildProcess, fork} from 'node:child_process';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a copy of the previous local-gateway, with a few added things:

  • llm is instantiated directly in here (specific to the local executor)
  • llm is destroyed/disposed here directly via the new destroy() hook
  • tryRepair for example got renamed (a couple of APIs got renamed..)
  • Exposes the config and e.g. getBuildCommand
  • Passes the build command, package manager etc to the Genkit codegen requests (needed for e.g. Gemini CLI runner)

llm.startMcpServerHost(hostName, this.config.mcpServers ?? []);
}

async collectMcpServerLogs() {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The MCP logic moved directly into the local executor as it's very specific to Genkit and was previously hard-coded into generate.ts. In the future we could have a generic API as part of Executor.

}

/** Request information for a file generation. */
export interface LlmGenerateFilesRequest {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unlike the genkit interface (which extends from this), normal LLM generate requests do not need e.g. buildCommand or packageManager in here. The local executor can inject this information for e.g. Gemini CLI based on the local executor configuration.

// Needed for portability of the `PQueue` type.
export type WorkerQueueType = PQueue;

export const executorSchema = z.object({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if we need a schema for the executor since it'll usually be a JS class instance. Maybe we should require users to extend some sort of base executor?

The reason why we have a schema for the environment config is that it's just an object literal.

Copy link
Member Author

@devversion devversion Oct 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can follow-up on this when we better support TypeScript. Right now this seems useful at least & isn't much more work/cost

): void {
): Promise<void> {
const runnerInfo =
env.executor instanceof LocalExecutor ? await env.executor.getRunnerInfo() : null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of checking for LocalExecutor in a few places, couldn't we move these methods into the base class/interface and have them be optional?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can move the runner info out, but other methods like for the templating/source directory I'd keep specific to the local executor.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed some of this (as much as possible). Good idea

@devversion devversion force-pushed the easier-local-gateway-reuse branch from 657aea8 to c6ff850 Compare October 7, 2025 17:20
* Renames `Gateway` to `Executor` with strict validation via Zod.
* Attaches executor specific configuration to the executor, instead of
  letting (previous) gateways extract information through multiple layer
  of indirections from the `Environment`.
  * This also resulted in lots of difficulties around generics and
    heritage.
* No longer passes around gateway, or executors as they can be directly
  accessed from the `Environment`.
* Adds a compatibility layer for old configs where the local executor is
  "assumed" and configured at the top-level environment config object.
* Updates the remote environment example with the new API.
* Improves the gateway/executor API to be better named and support async
  model validation, or destroying.
@devversion devversion force-pushed the easier-local-gateway-reuse branch from c6ff850 to 55c54c4 Compare October 7, 2025 17:21
@devversion devversion merged commit 37e35c8 into angular:main Oct 7, 2025
3 checks passed
@devversion devversion deleted the easier-local-gateway-reuse branch October 7, 2025 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants