Collaborative skill learning
Collaborative skill learning starts by requesting an agent to perform a task and then having a conversation with the agent to iteratively improve on that task. This is mainly achieved by improving the code actions the agent generates. In this phase the agent gets feedback from both the execution environment and the user. When the user is satisfied with the agent's performance, it stores optimized code actions as skills in long-term memory1. Since this is very similar to using a SWE agent, this phase is also called skill development. Stored skill modules can then be reused by other agents. These agents may also continue the skill development process, if needed.
Skill development
In the following example, an agent is asked to fit a Gaussian Process (GP) to noisy samples drawn from a sine function.
The user then asks the agent to store the generated code actions as functions gp_fit
(to fit a GP to data) and plot_pred
(to plot GP predictions) in a module named gp_fit.py
.
After reviewing the code of the stored skill module2, the user requests to change the default value of the n_restarts
parameter to 15
and the agent edits the stored module.
Finally, the module is tested with noisy samples from a cosine function.
import asyncio
import os
from rich.console import Console
from freeact import CodeActAgent, LiteCodeActModel, execution_environment
from freeact.cli.utils import stream_conversation
async def main():
async with execution_environment(
ipybox_tag="ghcr.io/gradion-ai/ipybox:example",
) as env:
async with env.code_executor() as executor:
model = LiteCodeActModel(
model_name="anthropic/claude-3-7-sonnet-20250219",
reasoning_effort="low",
api_key=os.getenv("ANTHROPIC_API_KEY"),
)
agent = CodeActAgent(model=model, executor=executor)
await stream_conversation(agent, console=Console())
if __name__ == "__main__":
asyncio.run(main())
Skill reuse
The next example loads the sources of the developed skill and tests it with another agent. The agent is asked to generate noisy samples from a non-linear function of its choice, fit them with a GP and plot the predictions. The agent now uses the developed skill immediately in its code actions.
Info
At the moment, it is an application's responsibility to load skill sources. We will soon enhance freeact
agents to retrieve skill sources autonomously depending on the user query and current state.
import asyncio
import os
from rich.console import Console
from freeact import CodeActAgent, LiteCodeActModel, execution_environment
from freeact.cli.utils import stream_conversation
async def main():
async with execution_environment(
ipybox_tag="ghcr.io/gradion-ai/ipybox:example",
) as env:
async with env.code_provider() as provider:
skill_sources = await provider.get_sources(
module_names=["gp_fit"], # (1)!
)
async with env.code_executor() as executor:
model = LiteCodeActModel(
model_name="anthropic/claude-3-7-sonnet-20250219",
reasoning_effort="low",
skill_sources=skill_sources,
api_key=os.getenv("ANTHROPIC_API_KEY"),
)
agent = CodeActAgent(model=model, executor=executor)
await stream_conversation(agent, console=Console())
if __name__ == "__main__":
asyncio.run(main())
- Loads the sources of the developed skill module.
uvx freeact \
--ipybox-tag=ghcr.io/gradion-ai/ipybox:example \
--model-name=anthropic/claude-3-7-sonnet-20250219 \
--reasoning-effort=low \
--skill-modules=gp_fit \
--api-key=$ANTHROPIC_API_KEY
uvx freeact \
--ipybox-tag=ghcr.io/gradion-ai/ipybox:basic \
--model-name=anthropic/claude-3-7-sonnet-20250219 \
--reasoning-effort=low \
--skill-modules=freeact_skills.search.google.stream.api \
--tracing
-
By default, Anthropic and OpenAI models are configured with a file editor tool for storing and editing skills. To configure this for other models, set
use_editor_tool=True
in the constructor ofLiteCodeActModel
. ↩ -
The stored skill module is accessible on the code execution container's host under
private_skills_host_path
, a directory mounted into the container. The path value can be obtained with:↩async with execution_environment(ipybox_tag="ghcr.io/gradion-ai/ipybox:example") as env: skills_path = env.container.workspace.private_skills_host_path ...