Coding Agent V2
Coding Agent V2 is an intelligent tool designed to simplify coding tasks within your Nappai automation workflows. Instead of just generating code immediately, this agent uses a sophisticated “deep reasoning” process to plan, verify, and refine the code before presenting the final result.
You can think of this component as a virtual developer that doesn’t just write lines of code, but actually thinks about the logic, checks for errors, and improves the solution iteratively. It is particularly useful for complex tasks like debugging, translating code between languages, or refactoring existing scripts to be more efficient.
How it Works
Internally, this component uses a structured graph-based approach (inspired by LangGraph) to manage coding tasks. When you provide an instruction, the agent doesn’t just output a single response. Instead, it goes through a multi-step cycle:
- Analysis: It reads your instructions and the context (if provided) to understand what needs to be done.
- Planning: It breaks down the task into smaller steps, deciding if it needs to create new code from scratch or edit existing files.
- Execution & Verification: It may execute the code in a safe environment to check if it works correctly. If errors are found, it automatically tries to fix them.
- Refinement: It reviews the final output to ensure it meets the requirements before sending it to you.
This process ensures that the code you receive is not only generated but also verified and optimized, reducing the need for manual debugging.
Connection & Credentials
This component is designed to work with remote servers, allowing you to manage files and scripts on external machines securely. To use this feature, you must configure an SSH Client credential.
Follow these steps to set up the connection:
- Go to the Credentials section in your Nappai panel.
- Create a new credential of the type SSH Client.
- Fill in the required fields, such as the SSH Hostname (the IP address or domain of the server), SSH Port (usually 22), SSH Username, and your Private Key or Password for authentication.
- Once saved, return to your workflow canvas.
- In the Credential input field of the Coding Agent V2 component, select the SSH Client credential you just created.
By linking your SSH credential, the agent can read, write, and edit files directly on your remote servers.
Operations
This component does not have selectable operations. It automatically performs the full coding lifecycle (Plan -> Write -> Verify -> Refine) based on the inputs you provide.
Inputs
The following fields are available to configure this component. Each field may be visible in different operations:
- Memory top message: [IntInput] Controls how much conversation history the agent uses as context. Enter a number to limit the number of past messages included, or enter
-1to include all available messages. This helps the agent maintain context during complex, multi-step conversations. - System Prompt: [MultilineInput] A hidden, internal setting that defines the agent’s behavior and constraints. This is managed automatically and is not intended for user modification.
- Just Dropped: [BoolInput] An internal technical flag used by the system to track when the component is placed on the canvas. This is not visible in the user interface.
- Enable SSH: [BoolInput] A toggle switch. Turn this On to allow the agent to connect to remote servers via SSH. Turn it Off if you only need local code generation without server access.
- SSH Allowed Hosts: [MultilineInput] A whitelist of server hostnames or IP addresses that the agent is allowed to connect to. Enter one hostname per line. If this field is left empty, the agent will use the hostname defined in the selected SSH Credential.
- SSH Allowed Paths: [MultilineInput] A whitelist of file paths that the agent is allowed to read or write on the remote server. Enter one path per line. This restricts the agent to specific directories for security.
- SSH Read-Only Mode: [BoolInput] When turned On, this prevents the agent from modifying or deleting files on the remote server. It can only read files and generate code locally. Use this for tasks where you only want to analyze code without making changes.
- Credential: [SelectInput] Select the SSH Client credential configured in the Credentials section to authenticate with remote servers.
Outputs
- Result: The final generated, edited, or analyzed code.
- Explanation: A text summary explaining the changes made, the logic used, or any errors encountered during the process.
- Files: A list of files that were created or modified during the operation, along with their paths.
Output Data Example (JSON)json
{ “result”: “def hello_world():\n print(‘Hello, Nappai!’)”, “explanation”: “The agent generated a simple Python function as requested. No errors were found during the verification step.”, “files”: [ { “path”: “/home/user/project/main.py”, “status”: “created” } ] }
Connectivity
In a typical Nappai workflow, this component is often connected to:
- Upstream: A Text Input or Code Snippet component that provides the initial task description or the code to be analyzed.
- Downstream: A Code Runner or File Writer component. The output from Coding Agent V2 (the corrected code) can be passed directly to a runner to execute the task, or to a file writer to save the new version to disk.
It is also frequently used in loops where the output is fed back into the component for further refinement if the first attempt didn’t meet the requirements.
Usage Example
Scenario: You have a Python script that is failing due to a logical error, and you need to fix it while keeping the file updated on your remote server.
- Prepare: Configure your SSH Client credential in Nappai.
- Configure Agent: Drag the Coding Agent V2 onto the canvas.
- Enable Enable SSH.
- Select your Credential.
- Set SSH Allowed Hosts to your server’s IP.
- Set SSH Read-Only Mode to Off (since you want to save the fixed code).
- Connect:
- Connect a Code Reader component (pointing to your remote script) to the agent’s code context input.
- Connect a Text Input containing the instruction: “Fix the logic error in the loop and optimize it.”
- Execute: Run the workflow. The agent will analyze the code, fix the error, verify it, and save the corrected version back to the remote server.
- Review: Check the Explanation output to understand what changes were made.
Tips and Best Practices
- Be Specific: Since the agent uses “deep reasoning,” detailed instructions yield better results. Instead of “fix this,” try “fix the off-by-one error in the for loop and add error handling.”
- Use Context: If you are editing existing code, always provide the current code in the input. This helps the agent understand the environment and make precise edits.
- Leverage Memory: If a task requires multiple steps, use the Memory top message input to keep the conversation context alive. Setting it to
-1ensures the agent remembers the entire history of the session. - Security First: Always define SSH Allowed Hosts and Paths to prevent the agent from accidentally modifying critical system files on your server.
Security Considerations
- SSH Security: Ensure your SSH credentials are stored securely in Nappai. The agent will have access to the remote server based on the permissions of the user account associated with the SSH key or password.
- Whitelisting: Use the SSH Allowed Hosts and SSH Allowed Paths inputs to restrict the agent’s access. This prevents the agent from inadvertently modifying files outside your intended scope.
- Read-Only Mode: For debugging or analysis tasks where no changes are needed, enable SSH Read-Only Mode to prevent any accidental file modifications.