Skip to main content

Code Agent User Guide

1. Background and Objectives

Through the Generic Code Agent template, users can quickly create a code-based intelligent agent (Code Agent) while completing both agent capability configuration and interactive interface (Agent UI) setup.

With AgenticHub, you can create intelligent assistants with Code / Article Generator Agent capabilities without writing code from scratch, significantly improving development and usage efficiency.


2. Accessing AgenticHub

Operation Steps:

  1. Log in to the Chuanshen Community
  2. Click on the top navigation bar: Applications → AgenticHub alt text
  3. After entering the AgenticHub workspace, you can see:
    • Left side: Templates / Instances / Tasks / Resources
    • Right side: Agent configuration and interaction area alt text

3. Creating a Code Agent Instance Using Templates

The platform provides a standard Generic_Code_Agent template for quickly creating code agents.

Operation Steps:

  1. Open the left-side Templates list
  2. Select the Generic_Code_Agent template
  3. Click Run on the right side of the template
  4. Fill in:
    • Instance name
    • Instance description
  5. Select and configure in order:
    • Model
    • Knowledge Base
    • Tools / MCP
    • Prompt
    • UI (default UI or custom UI) alt text
  6. After creation is complete, the instance will appear in the Instances list alt text

4. Deploying the Code Agent Instance

After creation, you need to deploy the code instance for the agent to run.

Operation Steps:

  1. Open the left-side Instances list
  2. Click on the target code instance
  3. After entering the instance details, click Agent Code
  4. Click Deploy Code
  5. After successful deployment:
    • The instance status will show as Running in Instances alt text

5. Enabling the Code Agent's UI Page

After deployment is complete, you can enable and access the agent's interactive UI.

Operation Steps:

  1. Open the left-side Instances list
  2. Click on the target code instance
  3. Click Agent Conversation
  4. Check Enable Custom UI (or use the default UI)
  5. The system will automatically open and display the Agent UI page alt text

6. Viewing Resource Lists (Models / Tools / Knowledge Bases / Prompts)

AgenticHub provides a unified resource management entry.

Operation Steps:

  1. Open the left-side Resources list
  2. By default, it displays the Tools list
  3. Click on different resources to view:
    • Knowledge Base → Knowledge Base list
    • Models → Models list
    • Prompts → Prompts list alt text
  4. In the Tools list:
    • Click on any tool configuration
    • You can view and edit the corresponding MCP Server configuration information alt text

7. Updating the Code Agent's Model / Tools / Knowledge Base / Prompts (Advanced)

When you need to modify agent capabilities, you can directly edit the code and redeploy.

7.1 Entering the Code Editing Page

Operation Steps:

  1. Open the left-side Instances list
  2. Click on the target code instance
  3. Click Agent Code
  4. Click Edit
  5. Open agent.py alt text

7.2 Updating the Model

In agent.py, the model variable is used to configure the model:

model = Model(
id="openai/deepseek-v3",
base_url="https://aigateway.opencsg-stg.com/v1",
api_key=os.getenv("MODEL_API_KEY"),
)

Explanation:

  • Change the model by modifying the id attribute (when using platform models, you need to add the openai/ prefix)

7.3 Updating Tools (MCP) and Knowledge Base

In the code:

  • mcp_group: Tool configuration
  • mcp_knowledge_base: Knowledge Base configuration
mcp_group = mcputil.Group(
# Weather query MCP service
mcp_builtin_8=mcputil.StreamableHTTP(
url="https://u-wanghh2003-free-weather-mcp-jn.public.opencsg-stg.com/mcp",
headers={},
),
# Knowledge Base MCP service
mcp_knowledge_base=mcputil.SSE(
url="https://agenthub.opencsg-stg.com:7861/api/v1/opencsg/rag/sse",
headers={
"Authorization": os.getenv("KNOWLEDGE_BASE_AUTHORIZATION")
},
),
)

Explanation:

  • Some MCPs require manual configuration of headers in the resource square, for example, gitlab mcp service requires configuration of personal token and gitlab domain name

  • The information in headers is written in the project's .env file and needs to be added synchronously in the .env file


7.4 Updating Prompts

In the code, the system variable is the system prompt:

system = """
You are a data analysis expert specialized in generating insights from complex datasets.
"""

Modifying this content will update the agent's behavior and role settings.

7.5 Redeploying the Code

After making any of the following modifications:

  • Model
  • Tools (MCP)
  • Knowledge Base
  • Prompts

You need to perform the following steps:

  1. Save the code
  2. Click Redeploy Code
  3. The modifications will take effect after successful deployment alt text