Skip to content

Commit b41f88e

Browse files
committed
Add CheckEnv job and enhance error handling for OAF_MODEL environment variable
1 parent 72f727e commit b41f88e

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

mini-a-web.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ include:
123123
- oJobHTTPd.yaml
124124

125125
todo:
126+
- CheckEnv
126127
- Init
127128
- Periodic cleanup of old sessions
128129
- Shutdown history S3 client
@@ -619,7 +620,7 @@ ojob:
619620
- oJob-common
620621
- mini-a
621622
- S3
622-
catch : printErrnl("[" + job.name + "] "); $err(exception, __, __, job.exec)
623+
catch : printErrnl("[" + job.name + "] "); printErr(exception)
623624
logToConsole: true # to change when finished
624625
daemon : true
625626
argsFromEnvs: true
@@ -634,6 +635,12 @@ ojob:
634635

635636
jobs:
636637
# ---------------------
638+
- name : CheckEnv
639+
exec : | #js
640+
if (isUnDef(getEnv("OAF_MODEL"))) {
641+
throw "OAF_MODEL environment variable not set. Please export OAF_MODEL with your model configuration before starting the Mini-A web server."
642+
}
643+
637644
- name : Static content
638645
exec : | #js
639646
args.path = getOPackPath("mini-a") + "/public"

mini-a.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2932,8 +2932,9 @@ MiniA.prototype.init = function(args) {
29322932

29332933
// Using OAF_MODEL env var for model selection
29342934
if (isUnDef(getEnv("OAF_MODEL"))) {
2935-
logErr("OAF_MODEL environment variable not set. Please set it to your desired LLM model.")
2936-
return
2935+
var _msg = "OAF_MODEL environment variable not set. Please set it to your desired LLM model."
2936+
logErr(_msg)
2937+
throw new Error(_msg)
29372938
}
29382939
// Check for the low-cost model in OAF_LC_MODEL
29392940
if (isDef(getEnv("OAF_LC_MODEL")) && isUnDef(this._oaf_lc_model)) {
@@ -3229,7 +3230,7 @@ MiniA.prototype.start = function(args) {
32293230
this.state = "stop"
32303231
var errMsg = (isDef(e) && isDef(e.message)) ? e.message : e
32313232
this.fnI("error", `Agent failed: ${errMsg}`)
3232-
throw e
3233+
return
32333234
}
32343235
}
32353236

mini-a.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,19 +160,26 @@ help:
160160
mandatory: false
161161

162162
todo:
163+
- CheckEnv
163164
- MiniAgent
164165

165166
ojob:
166167
opacks :
167168
- openaf: 20250725
168169
- mini-a
169-
catch : printErrnl("[" + job.name + "] "); $err(exception, __, __, job.exec)
170+
catch : printErrnl("[" + job.name + "] "); printErr(exception)
170171
logToConsole: false # to change when finished
171172
loadLibs :
172173
- mini-a.js
173174

174175
jobs:
175176
# ----------------
177+
- name : CheckEnv
178+
exec : | #js
179+
if (isUnDef(getEnv("OAF_MODEL"))) {
180+
throw "OAF_MODEL environment variable not set. Please export OAF_MODEL with your model configuration before running Mini-A."
181+
}
182+
176183
- name : MiniAgent
177184
check:
178185
in:

0 commit comments

Comments
 (0)