feat: add agentSchema and agentCode sync actions to ComponentBase #90
+378
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Adds two new built-in sync actions to
ComponentBasethat enable KAI (Keboola AI) to introspect and execute code against configured components at runtime:agentSchema: Auto-generates a schema describing the component viainspect— includes source code of the component class and imported modules, registered sync actions with docstrings, context variables with their types/methods, and installed packages. Components can overrideget_agent_schema()to customize or returnNoneto disable.agentCode: Executes arbitrary Python code (fromparameters.agent_code) inside the component's container. The code namespace includescomp(the initialized component instance) plus anything fromget_agent_context(). Results are returned via aresultvariable set in the executed code.Component authors only need to override
get_agent_context()(e.g., return{"sf": authenticated_client}) to expose initialized clients. Everything else is handled by the base class.Review & Testing Checklist for Human
exec()call:agent_coderunsexec(code, {'__builtins__': __builtins__}, local_ns)— full Python builtins are available, including__import__,open,eval. Confirm that the container sandbox is sufficient and that this action cannot be triggered outside the expected isolated Docker context. This is the highest-risk item._generate_agent_schemacallsget_agent_context()during schema generation (line 330): If a component'sget_agent_context()initializes an authenticated client,agentSchemawill attempt authentication just to populatecontext_variables. Decide whether schema generation should work without live credentials.agentSchemaandagentCodeare registered in_SYNC_ACTION_MAPPINGfor ALLComponentBasesubclasses at import time. Verify this doesn't conflict with existing components and that Developer Portal registration is the actual gating mechanism.agentCode: If executed code setsresultto a non-JSON-serializable object,process_sync_action_resultwill raise. No guard exists for this — confirm whether that's acceptable or if a serialization fallback is needed.agentSchema+agentCodeactions for a real component (e.g., component-salesforce-v2) in Developer Portal, runagentSchemato verify the generated schema is useful, then runagentCodewith a real snippet against live credentials to verify sub-second execution.Notes
config.jsonfiles on disk with try/finally restore — functional but fragile if test infrastructure changes.inspect.getsource()failures are silently caught, so schema may be sparse for C-extension-heavy components.Release Notes
Justification, description
Adds
agentSchemaandagentCodesync actions to enable KAI to programmatically introspect and interact with configured components at runtime with sub-second latency.Plans for Customer Communication
N/A — internal capability for KAI integration
Impact Analysis
Low risk to existing components — new actions are registered but require Developer Portal registration to be exposed. Components can opt-out by overriding
get_agent_schema()to returnNone.Deployment Plan
Standard release process
Rollback Plan
Revert commit and release previous version
Post-Release Support Plan
N/A