如果你要模仿 Claude CODE 和 Gemini CLI 自己实现一个 agent 命令行,并且希望你的 Agent 能够持续进行多轮对话,并且始终准确围绕用户提出的任务持续探索和行动,你需要从以下几个方面做优化:
- 对话历史管理
- 保存所有轮次的用户输入、Agent回复、工具调用请求与结果,并设计合适的“摘要”或“压缩”机制,避免 prompt 长度溢出。
- 优化历史内容选择,确保每轮对话都能带上最相关的任务信息(如目标描述、关键中间结果、约束条件)。
find in node_modules/
@google/gemini-cli-core/dist/src/core/contentGenerator.js
edit createContentGenerator
, add baseUrl
in httpOptions
.@google/gemini-cli-core/dist/src/core/geminiChat.js
edit contentGenerator.generateContent
, add httpOptions
as well1 | |
00:00:00,833 --> 00:00:05,433 | |
[音乐] | |
2 | |
00:00:07,733 --> 00:00:12,100 | |
[音乐] | |
3 | |
00:00:12,733 --> 00:00:18,166 |
``` | |
LampsRenderer received spatial event: SpatialEventCollection(events: [ | |
SwiftUI.SpatialEventCollection.Event.ID(value: 1): SwiftUI.SpatialEventCollection.Event( | |
id: SwiftUI.SpatialEventCollection.Event.ID(value: 1), | |
timestamp: 66374.834269625, | |
kind: SwiftUI.SpatialEventCollection.Event.Kind.indirectPinch, | |
location: (0.0, 0.0), | |
phase: SwiftUI.SpatialEventCollection.Event.Phase.active, | |
modifierKeys: SwiftUI.EventModifiers(rawValue: 0), | |
_inputDevicePose: Optional(SwiftUI.SpatialEventCollection.Event.InputDevicePose( |
const inner_width: f32 = {%inner_width%}; | |
const inner_height: f32 = {%inner_height%}; | |
const PI: f32 = 3.1415926535897932384626433832795; | |
@fragment | |
fn fragment_main(vs_out: VertexOut) -> @location(0) vec4<f32> { | |
// provide (x,y) in pixels, center is (0,0) | |
let pos = vs_out.pos; | |
let x = pos.x * inner_width * 0.5; |
# Use different pre-set defaults than the global defaults. | |
# | |
# See `src/bootstrap/defaults` for more information. | |
# Note that this has no default value (x.py uses the defaults in `config.example.toml`). | |
profile = 'dist' | |
[llvm] | |
download-ci-llvm = false | |
[build] |
Building bootstrap | |
Finished `dev` profile [unoptimized] target(s) in 0.98s | |
WARNING: The `change-id` is missing in the `config.toml`. This means that you will not be able to track the major changes made to the bootstrap configurations. | |
NOTE: to silence this warning, add `change-id = 127866` at the top of `config.toml` | |
Building stage0 library artifacts (aarch64-apple-darwin) | |
Compiling cc v1.0.99 | |
Compiling core v0.0.0 (/Users/jon.chen/work/container/rust/library/core) | |
Compiling libc v0.2.155 | |
Compiling memchr v2.5.0 | |
Compiling std v0.0.0 (/Users/jon.chen/work/container/rust/library/std) |
import Metal | |
import RealityKit | |
import SwiftUI | |
struct AttractorView: View { | |
let rootEntity: Entity = Entity() | |
let allSize: Int = 200000 | |
var vertexCapacity: Int { | |
return allSize * 4 | |
} |
caps download calcit-lang/calcit-clipboard@main | |
cr eval --dep calcit-clipboard/ 'thread-first (range 100) (map inc) (.join-str "|,") clipboard.core/copy!' |