Hawa Code CodeMode API OutputSchema Self-Evolution Learning

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

  1. Get the current GitHub account info
● Code(async () => {                              …
const me = await codemode.github.get_me();
return me;
})
⎿ {
"login": "jiweigang1",
"id": 3021648,
...
"updated_at": "2026-09-25T16:40:17Z"
}
}
  1. Query all repositories under the account
Code(async () => {                                                                                                                                     …
const repos = [];
let page = 1;
let total = 0;
while (page <= 3) {
const r = await codemode.github.search_repositories({ query: "user:jiweigang1 fork:false", sort: "updated", order: "desc", perPage: 100, page,
minimal_output: false });
if (!r || !r.items || r.items.length === 0) break;
total = r.total_count || 0;
repos.push(...r.items.filter(x => !x.fork).map(x => ({ name: x.full_name, default_branch: x.default_branch, pushed_at: x.updated_at })));
if (r.items.length < 100) break;
page++;
}
return { total, count: repos.length, repos };
})
⎿ {
"total": 46,
"count": 46,
...
}
]
}
  1. Get the parameters and description of the list_commits API method
● Code(async () => {                                                …
const docs = await codemode.describe("github.list_commits");
return docs;
})
⎿ {
"path": "github.list_commits",
"description": "Get list of commits of a branch in a GitHub repository. Returns at least 30 results per page by default, but can return more if
specified using the perPage parameter (up to 100).\n\n...
"types": "declare const github: {\n /**\n * Get list of commits of a branch in a GitHub repository. Returns at least 30 results per page by
default, but can return more if specified using the per...
"kind": "method"
}
  1. Try list_commits on the first repository to confirm the return structure.
● Code(async () => {                                                                                                              …
const r = await codemode.github.list_commits({ owner: "jiweigang1", repo: "hcode-pages", perPage: 100, fields: ["sha"] });
return { type: Array.isArray(r), len: Array.isArray(r) ? r.length : null, sample: Array.isArray(r) ? r[0] : r };
})
⎿ {
"type": true,
"len": 100,
"sample": {
"sha": "ae4e3858d448ea22cb6d3a4edef099f42bddb529"
}
}
  1. Infer the output schema and save it, while counting the project with the most commits
● Code(async () => {                                                                                                                                            …
await codemode.saveOutputSchema("github.list_commits", {
type: "array",
items: {
type: "object",
properties: {
sha: { type: "string" },
html_url: { type: "string" },
commit: {
type: "object",
properties: {
message: { type: "string" },
author: {
type: "object",
properties: {
name: { type: "string" },
email: { type: "string" },
date: { type: "string" }
}
},
committer: {
type: "object",
properties: {
name: { type: "string" },
email: { type: "string" },
date: { type: "string" }
}
}
}
},
author: {
type: "object",
nullable: true,
properties: {
login: { type: "string" },
id: { type: "number" }
}
},
committer: {
type: "object",
nullable: true,
properties: {
login: { type: "string" },
id: { type: "number" }
}
}
}
}
}, "list_commits returns an array of commit objects; fields depend on the fields parameter");

const repos = ["hcode-pages","all-skills","hawa-code","Agent-Toolkit","hawa-hands","hawa-computer-use","hawa-cli-analysis","hawa-code2","Appwite","claude
-code","MetaDesktop","blog","The-Story-of-the-Stone","claude-cookbooks","ucode-ide","claude-code-sdk","claude-code-starter","vsclilogger","agenter","deep-l
earning-newbie","MAmzGO","AmzGo","fine-dev","AlipayAmzGO","ByteBuddy-learning","Vercel","ad-agent","Dagger2-learning","maven-jar-template","WechatAmzgo","s
uperdisplay","test-app","AWS","hexo-theme-navy-at","hexo-theme-navy","Apm-Tester","ChromeDriver","GradleTest","asm-learning","resource","eshop","JgWidgets"
,"StreetBox","google-collections","wf","jg-table"];
const branches = { "hcode-pages":"master","hawa-computer-use":"master","hexo-theme-navy":"master","test-app":"master","GradleTest":"master","asm-learning
":"master","resource":"master","eshop":"master","StreetBox":"master","google-collections":"master","wf":"master","jg-table":"master","JgWidgets":"gh-pages"
};
const counts = [];
for (const repo of repos) {
let page = 1, total = 0;
while (true) {
const r = await codemode.github.list_commits({ owner: "jiweigang1", repo, sha: branches[repo] || "main", perPage: 100, page, fields: ["sha"] });
const len = Array.isArray(r) ? r.length : 0;
total += len;
if (len < 100) break;
page++;
if (page > 50) break; // safety limit: at most 5000 commits per repo
}
counts.push({ repo, total });
}
counts.sort((a, b) => b.total - a.total);
return counts;
})
⎿ [
{
"repo": "hcode-pages",
...
"total": 1
}
]
  1. hcode-pages has the most commits (3185). Next, count the commits per contributor for that project.
Code(async () => {                                                                                                                                     …
const perAuthor = {};
const perLogin = {};
let page = 1;
while (true) {
const r = await codemode.github.list_commits({ owner: "jiweigang1", repo: "hcode-pages", sha: "master", perPage: 100, page, fields: ["commit",
"author"] });
if (!Array.isArray(r) || r.length === 0) break;
for (const c of r) {
const name = c.commit && c.commit.author ? c.commit.author.name : "unknown";
perAuthor[name] = (perAuthor[name] || 0) + 1;
const login = c.author && c.author.login ? c.author.login : name;
perLogin[login] = (perLogin[login] || 0) + 1;
}
if (r.length < 100) break;
page++;
if (page > 60) break;
}
const byName = Object.entries(perAuthor).sort((a, b) => b[1] - a[1]);
const byLogin = Object.entries(perLogin).sort((a, b) => b[1] - a[1]);
return { pages: page, total: byName.reduce((s, x) => s + x[1], 0), byName, byLogin };
})
⎿ {
"pages": 32,
"total": 3185,
...
]
]
}

Statistics Result

Analysis complete. Here are the statistics (forked projects excluded, 46 non-fork repositories in total).

The project with the most commits

https://github.com/jiweigang1/hcode-pages — 3185 commits in total, far ahead of the second place hawa-code (1237 commits). This is a Hexo blog (GitHub Pages) repository that contains a large number of Hexo theme-related historical commits, which is why it has so many contributors (over a thousand by Git signature count).

Top 15 contributors of this project (by commit signature)

┌─────────────────────────┬──────────┐
│ Contributor │ Commits │
├─────────────────────────┼──────────┤
│ Tommy Chen (tommy351) │ 306 │
│ curbengh │ 193 │
│ jigang │ 122 │
│ lzjqsdd │ 116 │
│ Xuanwo │ 107 │
│ Abner Chou (NoahDragon) │ 78 │
│ dependabot[bot] │ 70 │
│ MDLeom │ 69 │
│ Sukka (SukkaW) │ 65 │
│ YoshinoriN │ 52 │
│ hexo-crowdin[bot] │ 46 │
│ 漩涡 │ 45 │
│ yoshinorin │ 44 │
│ D-Sketon │ 33 │
│ dependabot-preview[bot] │ 33 │
└─────────────────────────┴──────────┘

All other contributors have fewer than 30 commits; the vast majority have only 1~5 commits (many one-off upstream commits to Hexo themes/plugins).

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:

  1. Get the API description and the input/output parameter structures
  2. 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/