GLLM Core v0.3 to v0.4
Adding Custom Components
Overview
The Component API now supports an explicit main entrypoint via the @main decorator, with a resolver that determines which method to execute when calling run(). The legacy _run method remains supported as a fallback but is deprecated.
Resolution precedence for the main entrypoint:
Most derived method decorated with
@main.Method named by the
__main_method__class property.Legacy
_runmethod (deprecated fallback).
The input-parameter model (input_params) is generated from the resolved main method signature for the class.
Defining the main method (new)
Decorate an async instance method with
@main.Only one
@mainmethod per class is allowed.If multiple ancestors define different
@mainmethods, aTypeErroris raised unless the subclass explicitly overrides with its own@main.The
__main_method__class property is still supported but has lower precedence than@main. If both are present, a warning is logged and the decorator takes precedence.The main method must be asynchronous.
Example:
Migrating from the old Component
If your component previously implemented _run, you have two options.
Option A (minimal change): Keep
_runand add a thin@mainwrapperOption B (direct migration): Rename
_runto a meaningful name and apply@mainNotes:
If any code or tests directly called
_run, update those calls to use the new method orrun().input_paramswill now reflect the new method signature instead of_run.
Backward compatibility (non-migrated components)
Components that only implement
_runcontinue to work. The resolver falls back to_runand logs a deprecation warning recommending the@maindecorator.input_paramscontinues to be generated from_runin this case, so existing pipelines keep working.If both
@mainand__main_method__are defined, a warning is emitted and the decorator wins.
Multiple inheritance considerations
If two different ancestors define different
@mainmethods and the subclass does not explicitly override them, aTypeErroris raised at resolution time.To resolve, explicitly define a
@mainmethod in the subclass to choose the desired entrypoint.
Example resolution:
Troubleshooting
TypeError: "Main method '...' must be asynchronous" — ensure the method decorated with
@mainisasync def.TypeError: "Multiple main methods defined in X" — only one
@mainper class is allowed.TypeError about conflicting main methods across ancestors — add a
@mainmethod in the subclass to explicitly resolve.
Notes and best practices
Prefer an async instance method for the main entrypoint. Avoid using
@staticmethodor@classmethodwith@main.Keep the main method signature representative of the inputs you expect;
input_paramswill be generated from it.You do not need to document
run_profileorinput_paramsin your component’s docstring; these are derived and consumed by the pipeline.
Disabling Timeout with Retry Config
When defining a RetryConfig object, setting the timeout attribute to 0.0 will previously cause the timeout to be disabled. Now, setting it to 0.0 will raise an error. Instead, set it to None to disable timeout.
Disabling Timeout Example (v0.3) — Will Raise Error in v0.4
Disabling Timeout Example (v0.4)
Data Event Type Removal
The data event type is removed from the EventType constant. The special handling of the data event type across event handlers are also removed. This is a result of the simplification of the emitted event schema. For example, if a thinking event was previously formatted as such:
Now, it should be simplified as such:
Last updated