Skip to content

Conversation

@ZdenekSrotyr
Copy link

Summary

Adds two new built-in sync actions to ComponentBase that enable KAI (Keboola AI) to introspect and execute code against configured components at runtime:

  • agentSchema: Auto-generates a schema describing the component via inspect — 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 override get_agent_schema() to customize or return None to disable.
  • agentCode: Executes arbitrary Python code (from parameters.agent_code) inside the component's container. The code namespace includes comp (the initialized component instance) plus anything from get_agent_context(). Results are returned via a result variable 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

  • Security of exec() call: agent_code runs exec(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_schema calls get_agent_context() during schema generation (line 330): If a component's get_agent_context() initializes an authenticated client, agentSchema will attempt authentication just to populate context_variables. Decide whether schema generation should work without live credentials.
  • Global action registration: agentSchema and agentCode are registered in _SYNC_ACTION_MAPPING for ALL ComponentBase subclasses at import time. Verify this doesn't conflict with existing components and that Developer Portal registration is the actual gating mechanism.
  • Non-serializable results from agentCode: If executed code sets result to a non-JSON-serializable object, process_sync_action_result will raise. No guard exists for this — confirm whether that's acceptable or if a serialization fallback is needed.
  • End-to-end test plan: Register agentSchema + agentCode actions for a real component (e.g., component-salesforce-v2) in Developer Portal, run agentSchema to verify the generated schema is useful, then run agentCode with a real snippet against live credentials to verify sub-second execution.

Notes

Release Notes

Justification, description

Adds agentSchema and agentCode sync 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 return None.

Deployment Plan

Standard release process

Rollback Plan

Revert commit and release previous version

Post-Release Support Plan

N/A

Co-Authored-By: zdenek.srotyr@keboola.com <zdenek.srotyr@keboola.com>
@devin-ai-integration
Copy link

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

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.

1 participant