in a2a/a2a-server/src/commonMain/kotlin/ai/koog/a2a/server/tasks/InMemoryTaskStorage.kt [24:53]
override suspend fun get(
taskId: String,
historyLength: Int?,
includeArtifacts: Boolean
): Task? = rwLock.withReadLock {
historyLength?.let {
require(it >= 0) { "historyLength must be non-negative" }
}
val task = tasks[taskId] ?: return@withReadLock null
// Need to modify the original full task object to remove some information
val isModificationNeeded = historyLength != null || !includeArtifacts
if (isModificationNeeded) {
task.copy(
history = if (historyLength != null) {
task.history?.takeLast(historyLength)
} else {
task.history
},
artifacts = if (includeArtifacts) {
task.artifacts
} else {
null
}
)
} else {
task
}
}