1. Usage Example
Watch Hawa run a GitHub statistics task and see how Hawa Code autonomously identifies and fills in the missing OutputSchema in the Code Mode API.
Task
Analyze which project under my GitHub account has the most commits, and how many commits each contributor has made to that project. Exclude forked projects.
Execution Steps
- Get the current GitHub account info
● Code(async () => { … |
- Query all repositories under the account
Code(async () => { … |
- Get the parameters and description of the list_commits API method
● Code(async () => { … |
- Try list_commits on the first repository to confirm the return structure.
● Code(async () => { … |
- Infer the output schema and save it, while counting the project with the most commits
● Code(async () => { … |
- hcode-pages has the most commits (3185). Next, count the commits per contributor for that project.
Code(async () => { … |
Statistics Result
Analysis complete. Here are the statistics (forked projects excluded, 46 non-fork repositories in total). |
2. OutputSchema Self-Learning
2.1 Missing OutputSchema
Hawa Code converts MCP into Code Mode provider APIs, and then executes tasks by cascading calls to these APIs in JavaScript code.
MCP tools always provide an InputSchema, which ensures correct invocation, but many MCP tools do not provide an OutputSchema. This leaves the model unable to determine the shape of the return value, making cascading code calls impossible.
2.2 OutputSchema Inference
If an MCP tool does not provide an OutputSchema, a simple approach is to infer it from the tool’s return value. This works in most common scenarios, and there are two possible solutions:
- When executing a call, the program generates the OutputJSONSchema from the return value. The advantage is that no model involvement is required.
- The model autonomously determines the OutputJSONSchema. The advantage is higher accuracy.
Hawa Code adopts the second approach, which fits the Hawa Code philosophy: “models will get smarter and smarter, so they should be given more control.” It also improves accuracy — for example, if the return value is an enum, the model can refine the OutputJSONSchema across multiple return values.
In the example above, HawaCode first tried list_commits on one repository to confirm the return structure, then saved it. The model can choose various ways and the right timing to infer the OutputSchema structure.
2.3 Progressive Learning
In the example above, Hawa Code made multiple calls but greatly reduced the number of model invocations compared to traditional tool calling, which struggles with repeated paginated calls. As Hawa Code uses the GitHub API more and more, it progressively fills in the missing OutputSchema. If the OutputSchema were complete, Hawa Code could finish this task with just two model calls:
- Get the API description and the input/output parameter structures
- Execute the business logic code call.
Code Mode is well suited for complex business logic tasks that are hard for traditional tool calling, such as performing thousands of paginated calls.
Welcome to learn more about Hawa Code: https://www.hawacode.com/docs/