@hackerrank/astra-cli 0.1.17 → 0.1.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hackerrank/astra-cli",
3
- "version": "0.1.17",
3
+ "version": "0.1.19",
4
4
  "description": "Minimal zero-dependency AI coding agent for the HackerRank AI Gateway.",
5
5
  "type": "module",
6
6
  "bin": {
package/src/agent.js CHANGED
@@ -105,7 +105,11 @@ export class Agent {
105
105
 
106
106
  apiMessages() {
107
107
  return this.messages
108
- .filter((m) => m.role === "system" || m.role === "user" || m.role === "assistant")
108
+ .filter(
109
+ (m) =>
110
+ (m.role === "system" || m.role === "user") ||
111
+ (m.role === "assistant" && m.content !== "")
112
+ )
109
113
  .map((m) => ({ role: m.role, content: m.content }));
110
114
  }
111
115
 
@@ -131,7 +135,7 @@ export class Agent {
131
135
  throw err;
132
136
  }
133
137
  this.lastContextTokens = usage.prompt_tokens;
134
- this.add("assistant", content, { usage });
138
+ if (content !== "") this.add("assistant", content, { usage });
135
139
 
136
140
  this.onStep({
137
141
  step: this.nSteps,
package/src/model.js CHANGED
@@ -66,8 +66,9 @@ export class GatewayModel {
66
66
  this.reportedCostUsd = 0;
67
67
  this.estimatedCostUsd = 0;
68
68
  this.costSource = null; // "reported" | "estimated" | "mixed" | null
69
- // Preferred token-cap parameter; swapped automatically on 400 if needed.
70
- this._tokenParam = "max_tokens";
69
+ // GPT-family gateway routes use the newer completion-token parameter.
70
+ // Other OpenAI-compatible providers continue using the legacy parameter.
71
+ this._tokenParam = /^gpt(?:-|$)/i.test(model) ? "max_completion_tokens" : "max_tokens";
71
72
  // Optional AbortSignal; when set and aborted, in-flight requests are
72
73
  // cancelled (used to force-quit a long model call on a second Ctrl+C).
73
74
  this.signal = null;