Skip to content

Agent

Routes GitHub events (repo + event_type) to configured agent URLs.

CLASS DESCRIPTION
RouteTarget

The resolved destination for a routed event.

Router

Maps GitHub events to agent URLs based on the Foreman config.

RoutingError

Raised when a repo is not found in the Foreman config.

Classes

RouteTarget dataclass

RouteTarget(url: str, agent_assignment: AgentAssignment)

The resolved destination for a routed event.

ATTRIBUTE DESCRIPTION
PARAMETER DESCRIPTION
url

TYPE: str

agent_assignment

TYPE: AgentAssignment

Router

Router(config: ForemanConfig)

Maps GitHub events to agent URLs based on the Foreman config.

Initialised once at startup with the parsed config. The container lifecycle manager calls :meth:register_url after each agent container starts so that dynamically-assigned ports are used at dispatch time.

PARAMETER DESCRIPTION
config

Validated :class:~foreman.config.ForemanConfig.

TYPE: ForemanConfig

METHOD DESCRIPTION
register_url

Register a runtime URL for agent_type.

route

Return the :class:RouteTarget for event_type in repo, or None.

Functions

register_url
register_url(agent_type: str, url: str) -> None

Register a runtime URL for agent_type.

Overrides any url value from the YAML config. Called by the container lifecycle manager after a container is started.

PARAMETER DESCRIPTION
agent_type

Agent type identifier (e.g. "issue-triage").

TYPE: str

url

Base URL of the running container (e.g. "http://localhost:9001").

TYPE: str

route
route(event_type: str, repo: str) -> RouteTarget | None

Return the :class:RouteTarget for event_type in repo, or None.

PARAMETER DESCRIPTION
event_type

GitHub event type string (e.g. "issue.triage").

TYPE: str

repo

Repository in owner/repo format.

TYPE: str

RETURNS DESCRIPTION
A

class:RouteTarget when a matching agent with a known URL is

TYPE: RouteTarget | None

RouteTarget | None

found, or None when no agent handles this event type.

RAISES DESCRIPTION
RoutingError

When repo is not present in the config.

RoutingError

Bases: Exception

Raised when a repo is not found in the Foreman config.