AQIT
0.1.0
Toggle main menu visibility
Loading...
Searching...
No Matches
agent_bootstrap.py
Go to the documentation of this file.
1
# Copyright (c) 2025-present Aquin Labs Private Limited. All Rights Reserved.
2
# This file is part of the Aquin Engine. Unauthorized copying, modification,
3
# distribution, or use of this file, via any medium, is strictly prohibited.
4
# Proprietary and confidential. See LICENSE for terms.
5
6
"""
7
Dump system prompt + OpenAI tool schemas for the Node agent loop.
8
9
python -m aquin.engine.agent_bootstrap
10
python -m aquin.engine.agent_bootstrap --model <id>
11
12
Stdout: one JSON object { system, tools, state }.
13
"""
14
from
__future__
import
annotations
15
16
import
argparse
17
import
json
18
import
sys
19
from
typing
import
Any
20
21
22
def
main
() -> int:
23
parser = argparse.ArgumentParser(prog=
"aquin-agent-bootstrap"
)
24
parser.add_argument(
"--model"
, default=
None
, help=
"optional active model id for tool filter"
)
25
ns = parser.parse_args()
26
27
# Windows consoles often use cp1252 — force UTF-8 for JSON stdout.
28
try
:
29
sys.stdout.reconfigure(encoding=
"utf-8"
)
30
except
Exception:
31
pass
32
33
state: dict[str, Any] = {}
34
if
ns.model:
35
state[
"activeModelId"
] = ns.model
36
else
:
37
try
:
38
from
aquin.compute.model_loader
import
get_active_model_id
39
40
mid = get_active_model_id()
41
if
mid:
42
state[
"activeModelId"
] = mid
43
except
Exception:
44
pass
45
46
try
:
47
from
aquin.engine.agent
import
_build_tools_schema, _load_system_prompt
48
49
system = _load_system_prompt(state)
50
tools = _build_tools_schema(state)
51
except
Exception
as
exc:
52
_write_json
({
"ok"
:
False
,
"error"
: str(exc)})
53
return
1
54
55
# Fallback: always expose model-free memory tools so Node can demo agents
56
# even when no model is loaded (empty schema from session_mode).
57
if
not
tools:
58
tools = [
59
{
60
"type"
:
"function"
,
61
"function"
: {
62
"name"
:
"write_session_memory"
,
63
"description"
:
"Persist a key/value pair to session memory."
,
64
"parameters"
: {
65
"type"
:
"object"
,
66
"properties"
: {
67
"key"
: {
"type"
:
"string"
},
68
"value"
: {},
69
},
70
"required"
: [
"key"
,
"value"
],
71
},
72
},
73
},
74
{
75
"type"
:
"function"
,
76
"function"
: {
77
"name"
:
"read_session_memory"
,
78
"description"
:
"Read a previously stored key from session memory."
,
79
"parameters"
: {
80
"type"
:
"object"
,
81
"properties"
: {
"key"
: {
"type"
:
"string"
}},
82
"required"
: [
"key"
],
83
},
84
},
85
},
86
]
87
88
_write_json
({
"ok"
:
True
,
"system"
: system,
"tools"
: tools,
"state"
: state})
89
return
0
90
91
92
def
_write_json
(payload: dict[str, Any]) ->
None
:
93
data = json.dumps(payload, ensure_ascii=
False
) +
"\n"
94
try
:
95
sys.stdout.buffer.write(data.encode(
"utf-8"
))
96
sys.stdout.buffer.flush()
97
except
Exception:
98
# Last resort: ASCII-escaped JSON
99
print(json.dumps(payload, ensure_ascii=
True
), flush=
True
)
100
101
102
if
__name__ ==
"__main__"
:
103
sys.exit(
main
())
aquin.compute.model_loader
Definition
model_loader.py:1
aquin.engine.agent_bootstrap._write_json
None _write_json(dict[str, Any] payload)
Definition
agent_bootstrap.py:96
aquin.engine.agent_bootstrap.main
int main()
Definition
agent_bootstrap.py:26
aquin.engine.agent
Definition
agent.py:1
aquin
engine
agent_bootstrap.py
AQIT · Aquin Labs Private Limited · Apache 2.0 · Generated by
1.18.0